lineendings community server

This commit is contained in:
Ulf Gebhardt 2021-03-30 17:05:16 +02:00
parent 45557a55c0
commit d4d9a22164
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
24 changed files with 2191 additions and 2191 deletions

View File

@ -1,17 +1,17 @@
FROM phpdockerio/php74-fpm
# install php fpm
RUN apt-get update \
&& apt-get -y --no-install-recommends install curl unzip php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
WORKDIR /var/www/cakephp
RUN mkdir logs && mkdir tmp && chmod 777 logs && chmod 777 tmp
COPY ./community_server/ .
COPY ./configs/community_server/app.php ./config/
RUN composer update
RUN composer dump-autoload
FROM phpdockerio/php74-fpm
# install php fpm
RUN apt-get update \
&& apt-get -y --no-install-recommends install curl unzip php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
WORKDIR /var/www/cakephp
RUN mkdir logs && mkdir tmp && chmod 777 logs && chmod 777 tmp
COPY ./community_server/ .
COPY ./configs/community_server/app.php ./config/
RUN composer update
RUN composer dump-autoload

View File

@ -1,25 +1,25 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@ -1,88 +1,88 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -1,86 +1,86 @@
server {
listen 80 ;
listen [::]:80;
server_name 0.0.0.0;
#include /etc/nginx/common/protect.conf;
#include /etc/nginx/common/protect_add_header.conf;
#include /etc/nginx/common/ssl.conf;
root /usr/share/nginx/html/webroot;
index index.php;
location ~* \.(png|jpg|ico|webp)\$ {
expires 30d;
}
location ~* \.(js|css) {
# expires 1d;
expires 1d;
}
location ~ \.php\$ {
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
#fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
location /account {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /account/(.*) /\$1 break;
#proxy_next_upstream error timeout invalid_header http_502 non_idempotent;
proxy_pass http://login-server:1200;
proxy_redirect off;
}
location /login_api {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /login_api/(.*) /\$1 break;
proxy_pass http://login-server:1201;
proxy_redirect off;
}
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
# access_log /var/log/nginx/access.log main;
server {
listen 80 ;
listen [::]:80;
server_name 0.0.0.0;
#include /etc/nginx/common/protect.conf;
#include /etc/nginx/common/protect_add_header.conf;
#include /etc/nginx/common/ssl.conf;
root /usr/share/nginx/html/webroot;
index index.php;
location ~* \.(png|jpg|ico|webp)\$ {
expires 30d;
}
location ~* \.(js|css) {
# expires 1d;
expires 1d;
}
location ~ \.php\$ {
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
#fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
location /account {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /account/(.*) /\$1 break;
#proxy_next_upstream error timeout invalid_header http_502 non_idempotent;
proxy_pass http://login-server:1200;
proxy_redirect off;
}
location /login_api {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /login_api/(.*) /\$1 break;
proxy_pass http://login-server:1201;
proxy_redirect off;
}
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
# access_log /var/log/nginx/access.log main;
}

View File

@ -1,8 +1,8 @@
CREATE TABLE `community_profiles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`state_user_id` int(10) unsigned NOT NULL,
`profile_img` longblob,
`profile_desc` varchar(2000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `state_user_id` (`state_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `community_profiles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`state_user_id` int(10) unsigned NOT NULL,
`profile_img` longblob,
`profile_desc` varchar(2000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `state_user_id` (`state_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@ -1,71 +1,71 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Http\Client;
use Cake\Core\Configure;
use Datto\JsonRpc\Client as JsonRpcClient;
//App\Controller\Component\ComponentRegistry
class JsonRpcRequestClientComponent extends Component
{
var $rpcClient = null;
public function __construct($registry, array $config = array()) {
parent::__construct($registry, $config);
$this->rpcClient = new JsonRpcClient();
}
// @param id: if id = 0 call rand for it
public function request($method, $params = [], $id = 0)
{
if(0 == $id) {
$id = random_int(1, 12000);
}
$this->rpcClient->query($id, $method, $params);
$message = $this->rpcClient->encode();
return $this->sendRequest($message);
// message: {"jsonrpc":"2.0","method":"add","params":[1,2],"id":1}
}
public function sendRequest($message) {
$http = new Client();
$response = $http->post($this->getGradidoNodeUrl(), $message, ['type' => 'json']);
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus];
}
//$responseType = $response->getType();
//if($responseType != 'application/json') {
// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType];
// }
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return $json;
//return ['state' => 'success', 'data' => $json];
}
static public function getGradidoNodeUrl()
{
$gradidoNode = Configure::read('GradidoNode');
return $gradidoNode['host'] . ':' . $gradidoNode['port'];
}
}
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Http\Client;
use Cake\Core\Configure;
use Datto\JsonRpc\Client as JsonRpcClient;
//App\Controller\Component\ComponentRegistry
class JsonRpcRequestClientComponent extends Component
{
var $rpcClient = null;
public function __construct($registry, array $config = array()) {
parent::__construct($registry, $config);
$this->rpcClient = new JsonRpcClient();
}
// @param id: if id = 0 call rand for it
public function request($method, $params = [], $id = 0)
{
if(0 == $id) {
$id = random_int(1, 12000);
}
$this->rpcClient->query($id, $method, $params);
$message = $this->rpcClient->encode();
return $this->sendRequest($message);
// message: {"jsonrpc":"2.0","method":"add","params":[1,2],"id":1}
}
public function sendRequest($message) {
$http = new Client();
$response = $http->post($this->getGradidoNodeUrl(), $message, ['type' => 'json']);
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus];
}
//$responseType = $response->getType();
//if($responseType != 'application/json') {
// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType];
// }
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return $json;
//return ['state' => 'success', 'data' => $json];
}
static public function getGradidoNodeUrl()
{
$gradidoNode = Configure::read('GradidoNode');
return $gradidoNode['host'] . ':' . $gradidoNode['port'];
}
}

View File

@ -22,9 +22,9 @@ class Key extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type string $ed25519
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
* @type string $ed25519_ref10
* ed25519 ref10 signature
* ed25519 ref10 signature
* }
*/
public function __construct($data = NULL) {
@ -33,7 +33,7 @@ class Key extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
*
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
* @return string
@ -44,7 +44,7 @@ class Key extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
*
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
* @param string $var
@ -59,7 +59,7 @@ class Key extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 ref10 signature
* ed25519 ref10 signature
*
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
* @return string
@ -70,7 +70,7 @@ class Key extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 ref10 signature
* ed25519 ref10 signature
*
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
* @param string $var

View File

@ -22,7 +22,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message
*/
private $amount = 0;
/**
* sender balance after transaction, including perishability
* sender balance after transaction, including perishability
*
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
*/
@ -37,7 +37,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message
* @type string $ed25519_sender_pubkey
* @type int|string $amount
* @type int|string $senderFinalBalance
* sender balance after transaction, including perishability
* sender balance after transaction, including perishability
* }
*/
public function __construct($data = NULL) {
@ -90,7 +90,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message
}
/**
* sender balance after transaction, including perishability
* sender balance after transaction, including perishability
*
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
* @return int|string
@ -101,7 +101,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message
}
/**
* sender balance after transaction, including perishability
* sender balance after transaction, including perishability
*
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
* @param int|string $var

View File

@ -14,7 +14,7 @@ use Google\Protobuf\Internal\GPBUtil;
class SignatureMap extends \Google\Protobuf\Internal\Message
{
/**
* Each signature pair corresponds to a unique Key required to sign the transaction.
* Each signature pair corresponds to a unique Key required to sign the transaction.
*
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
*/
@ -27,7 +27,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $sigPair
* Each signature pair corresponds to a unique Key required to sign the transaction.
* Each signature pair corresponds to a unique Key required to sign the transaction.
* }
*/
public function __construct($data = NULL) {
@ -36,7 +36,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message
}
/**
* Each signature pair corresponds to a unique Key required to sign the transaction.
* Each signature pair corresponds to a unique Key required to sign the transaction.
*
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
* @return \Google\Protobuf\Internal\RepeatedField
@ -47,7 +47,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message
}
/**
* Each signature pair corresponds to a unique Key required to sign the transaction.
* Each signature pair corresponds to a unique Key required to sign the transaction.
*
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
* @param \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $var

View File

@ -27,9 +27,9 @@ class SignaturePair extends \Google\Protobuf\Internal\Message
*
* @type string $pubKey
* @type string $ed25519
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
* @type string $ed25519_ref10
* ed25519 ref10 signature
* ed25519 ref10 signature
* }
*/
public function __construct($data = NULL) {
@ -60,7 +60,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
*
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
* @return string
@ -71,7 +71,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 signature (libsodium default)
* ed25519 signature (libsodium default)
*
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
* @param string $var
@ -86,7 +86,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 ref10 signature
* ed25519 ref10 signature
*
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
* @return string
@ -97,7 +97,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message
}
/**
* ed25519 ref10 signature
* ed25519 ref10 signature
*
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
* @param string $var

View File

@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
* need signature from this group and from parent (if it isn't zero)
* need signature from this group and from parent (if it isn't zero)
*
* Generated from protobuf message <code>model.messages.gradido.StateCreateGroup</code>
*/

View File

@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
* need signature from this group and from both parents (if it isn't zero)
* need signature from this group and from both parents (if it isn't zero)
*
* Generated from protobuf message <code>model.messages.gradido.StateGroupChangeParent</code>
*/

View File

@ -16,13 +16,13 @@ use Google\Protobuf\Internal\GPBUtil;
class Timestamp extends \Google\Protobuf\Internal\Message
{
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
*/
private $seconds = 0;
/**
* Number of nanoseconds since the start of the last second
* Number of nanoseconds since the start of the last second
*
* Generated from protobuf field <code>int32 nanos = 2;</code>
*/
@ -35,9 +35,9 @@ class Timestamp extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type int|string $seconds
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
* @type int $nanos
* Number of nanoseconds since the start of the last second
* Number of nanoseconds since the start of the last second
* }
*/
public function __construct($data = NULL) {
@ -46,7 +46,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message
}
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
* @return int|string
@ -57,7 +57,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message
}
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
* @param int|string $var
@ -72,7 +72,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message
}
/**
* Number of nanoseconds since the start of the last second
* Number of nanoseconds since the start of the last second
*
* Generated from protobuf field <code>int32 nanos = 2;</code>
* @return int
@ -83,7 +83,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message
}
/**
* Number of nanoseconds since the start of the last second
* Number of nanoseconds since the start of the last second
*
* Generated from protobuf field <code>int32 nanos = 2;</code>
* @param int $var

View File

@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
class TimestampSeconds extends \Google\Protobuf\Internal\Message
{
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
*/
@ -29,7 +29,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type int|string $seconds
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
* }
*/
public function __construct($data = NULL) {
@ -38,7 +38,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message
}
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
* @return int|string
@ -49,7 +49,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message
}
/**
* Number of complete seconds since the start of the epoch
* Number of complete seconds since the start of the epoch
*
* Generated from protobuf field <code>int64 seconds = 1;</code>
* @param int|string $var

View File

@ -9,27 +9,27 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
* need signature from group admin or
* percent of group users another than the receiver
* need signature from group admin or
* percent of group users another than the receiver
*
* Generated from protobuf message <code>model.messages.gradido.TransactionCreation</code>
*/
class TransactionCreation extends \Google\Protobuf\Internal\Message
{
/**
* 40 Byte
* 40 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
*/
private $receiverAmount = null;
/**
* 4 Byte
* 4 Byte
*
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
*/
private $ident_hash = 0;
/**
* 8 Byte
* 8 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
*/
@ -42,11 +42,11 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type \Model\Messages\Gradido\ReceiverAmount $receiverAmount
* 40 Byte
* 40 Byte
* @type int $ident_hash
* 4 Byte
* 4 Byte
* @type \Model\Messages\Gradido\TimestampSeconds $target_date
* 8 Byte
* 8 Byte
* }
*/
public function __construct($data = NULL) {
@ -55,7 +55,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 40 Byte
* 40 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
* @return \Model\Messages\Gradido\ReceiverAmount
@ -66,7 +66,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 40 Byte
* 40 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
* @param \Model\Messages\Gradido\ReceiverAmount $var
@ -81,7 +81,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 4 Byte
* 4 Byte
*
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
* @return int
@ -92,7 +92,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 4 Byte
* 4 Byte
*
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
* @param int $var
@ -107,7 +107,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 8 Byte
* 8 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
* @return \Model\Messages\Gradido\TimestampSeconds
@ -118,7 +118,7 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
}
/**
* 8 Byte
* 8 Byte
*
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
* @param \Model\Messages\Gradido\TimestampSeconds $var

View File

@ -1,269 +1,269 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Model\Transactions;
//use Model\Messages\Gradido\Transaction;
//use Model\Messages\Gradido\TransactionBody;
use Cake\ORM\TableRegistry;
use Cake\Datasource\ConnectionManager;
class Transaction extends TransactionBase {
private $mProtoTransaction = null;
private $mTransactionBody = null;
public function __construct($base64Data)
{
//$transactionBin = base64_decode($base64Data, true);
//if($transactionBin == false) {
//sodium_base64_VARIANT_URLSAFE_NO_PADDING
if(is_a($base64Data, '\Model\Messages\Gradido\Transaction')) {
$this->mProtoTransaction = $base64Data;
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
return;
}
try {
$transactionBin = sodium_base642bin($base64Data, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING);
} catch(\SodiumException $e) {
//$this->addError('Transaction', $e->getMessage());// . ' ' . $base64Data);
//return;
$transactionBin = base64_decode($base64Data, true);
if($transactionBin == false) {
$this->addError('Transaction', $e->getMessage());// . ' ' . $base64Data);
return;
}
}
//*/}
if($transactionBin == false) {
//$this->addError('base64 decode failed');
$this->addError('Transaction', 'base64 decode error: ' . $base64Data);
} else {
//var_dump($transactionBin);
$this->mProtoTransaction = new \Model\Messages\Gradido\Transaction();
try {
$this->mProtoTransaction->mergeFromString($transactionBin);
//var_dump($this->mProtoTransaction);
// cannot catch Exception with cakePHP, I don't know why
} catch(\Google\Protobuf\Internal\GPBDecodeException $e) {
//var_dump($e);
$this->addError('Transaction', $e->getMessage());
return;
}//*/
//echo 'serialize to json: <br>';
//echo $this->mProtoTransaction->serializeToJsonString();
//echo "body bytes: <br>";
//var_dump($this->mProtoTransaction->getBodyBytes());
//echo "<br>end body bytes<br>";
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
}
}
static public function build(\Model\Messages\Gradido\TransactionBody $transactionBody, $senderKeyPair)
{
$protoTransaction = new \Model\Messages\Gradido\Transaction();
$recevied = new \Model\Messages\Gradido\TimestampSeconds();
$recevied->setSeconds(time());
$protoTransaction->setReceived($recevied);
$bodyBytes = $transactionBody->serializeToString();
$sigMap = SignatureMap::build($bodyBytes, [$senderKeyPair]);
$protoTransaction->setSigMap($sigMap->getProto());
$protoTransaction->setBodyBytes($bodyBytes);
return $protoTransaction;
}
public function getTransactionBody() {
return $this->mTransactionBody;
}
public function getFirstPublic() {
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
return $sigPairs[0]->getPubKey();
}
public function getId() {
return $this->mProtoTransaction->getId();
}
public function validate() {
$sigMap = $this->mProtoTransaction->getSigMap();
if(!$sigMap) {
$this->addError('Transaction', 'signature map is zero');
return false;
}
//var_dump($sigMap);
//die();
$sigPairs = $sigMap->getSigPair();
$bodyBytes = $this->mProtoTransaction->getBodyBytes();
if(!$sigPairs || count($sigPairs) < 1) {
$this->addError('Transaction::validate', 'no signature found');
return false;
}
// check signature(s)
foreach($sigPairs as $sigPair) {
//echo 'sig Pair: '; var_dump($sigPair); echo "<br>";
$pubkey = $sigPair->getPubKey();
$signature = $sigPair->getEd25519();
//echo "verify bodybytes: <br>" . bin2hex($bodyBytes) . '<br>';
if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) {
$this->addError('Transaction::validate', 'signature for key ' . bin2hex($pubkey) . ' isn\'t valid ' );
return false;
}
}
if(!$this->mTransactionBody->validate($sigPairs)) {
$this->addErrors($this->mTransactionBody->getErrors());
return false;
}
return true;
}
public function save()
{
$connection = ConnectionManager::get('default');
$connection->begin();
//id transaction_id signature pubkey
if (!$this->mTransactionBody->save($this->getFirstPublic(), $this->mProtoTransaction->getSigMap())) {
$this->addErrors($this->mTransactionBody->getErrors());
$connection->rollback();
return false;
}
// save transaction signatures
$transactionsSignaturesTable = TableRegistry::getTableLocator()->get('transaction_signatures');
$transactionId = $this->mTransactionBody->getTransactionID();
//signature pubkey
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
//echo "sigPairs: "; var_dump($sigPairs);
$signatureEntitys = [];
foreach($sigPairs as $sigPair) {
$signatureEntity = $transactionsSignaturesTable->newEntity();
$signatureEntity->transaction_id = $transactionId;
$signatureEntity->signature = $sigPair->getEd25519();
$signatureEntity->pubkey = $sigPair->getPubKey();
array_push($signatureEntitys, $signatureEntity);
}
//debug($signatureEntitys);
if(!$transactionsSignaturesTable->saveMany($signatureEntitys)) {
foreach($signatureEntitys as $entity) {
$errors = $entity->getErrors();
if(!$errors && count($errors) > 0) {
$pubkeyHex = bin2hex($entity->pubkey);
$this->addError('Transaction::save', 'error saving signature for pubkey: ' . $pubkeyHex . ', with errors: ' . json_encode($errors) );
}
}
$connection->rollback();
return false;
}
$connection->commit();
$this->mTransactionBody->getSpecificTransaction()->sendNotificationEmail($this->mTransactionBody->getMemo());
return true;
}
static public function fromTable($id)
{
$transactionsTable = TableRegistry::getTableLocator()->get('transactions');
$transactionEntry = $transactionsTable
->find('all')
->where(['id' => $id])
->contain([
'TransactionCreations',
'TransactionSendCoins',
'TransactionSignatures'])
->first();
//var_dump($transactionEntry->toArray());
$protoTransaction = new \Model\Messages\Gradido\Transaction();
$protoTransaction->setId($transactionEntry->id);
$recevied = new \Model\Messages\Gradido\TimestampSeconds();
$recevied->setSeconds($transactionEntry->received->getTimestamp());
$protoTransaction->setReceived($recevied);
$sigMap = SignatureMap::fromEntity($transactionEntry->transaction_signatures);
$protoTransaction->setSigMap($sigMap->getProto());
//echo "sig map: check<br>";
$protoTransaction->setTxHash(stream_get_contents($transactionEntry->tx_hash));
$body = TransactionBody::fromEntity($transactionEntry->memo, $transactionEntry);
if(is_array($body)) {
return ['state' => 'error', 'msg' => 'error creating body transaction', 'details' => $body];
}
// validate signatures
$sigPairs = $sigMap->getProto()->getSigPair();
if(!$sigPairs || count($sigPairs) < 1) {
return ['state' => 'error', 'msg' => 'error no signatures found'];
}
//echo "verify bodybytes: <br>" . bin2hex($bodyBytes) . '<br>';
$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 "<br>";
$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;
}
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Model\Transactions;
//use Model\Messages\Gradido\Transaction;
//use Model\Messages\Gradido\TransactionBody;
use Cake\ORM\TableRegistry;
use Cake\Datasource\ConnectionManager;
class Transaction extends TransactionBase {
private $mProtoTransaction = null;
private $mTransactionBody = null;
public function __construct($base64Data)
{
//$transactionBin = base64_decode($base64Data, true);
//if($transactionBin == false) {
//sodium_base64_VARIANT_URLSAFE_NO_PADDING
if(is_a($base64Data, '\Model\Messages\Gradido\Transaction')) {
$this->mProtoTransaction = $base64Data;
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
return;
}
try {
$transactionBin = sodium_base642bin($base64Data, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING);
} catch(\SodiumException $e) {
//$this->addError('Transaction', $e->getMessage());// . ' ' . $base64Data);
//return;
$transactionBin = base64_decode($base64Data, true);
if($transactionBin == false) {
$this->addError('Transaction', $e->getMessage());// . ' ' . $base64Data);
return;
}
}
//*/}
if($transactionBin == false) {
//$this->addError('base64 decode failed');
$this->addError('Transaction', 'base64 decode error: ' . $base64Data);
} else {
//var_dump($transactionBin);
$this->mProtoTransaction = new \Model\Messages\Gradido\Transaction();
try {
$this->mProtoTransaction->mergeFromString($transactionBin);
//var_dump($this->mProtoTransaction);
// cannot catch Exception with cakePHP, I don't know why
} catch(\Google\Protobuf\Internal\GPBDecodeException $e) {
//var_dump($e);
$this->addError('Transaction', $e->getMessage());
return;
}//*/
//echo 'serialize to json: <br>';
//echo $this->mProtoTransaction->serializeToJsonString();
//echo "body bytes: <br>";
//var_dump($this->mProtoTransaction->getBodyBytes());
//echo "<br>end body bytes<br>";
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
}
}
static public function build(\Model\Messages\Gradido\TransactionBody $transactionBody, $senderKeyPair)
{
$protoTransaction = new \Model\Messages\Gradido\Transaction();
$recevied = new \Model\Messages\Gradido\TimestampSeconds();
$recevied->setSeconds(time());
$protoTransaction->setReceived($recevied);
$bodyBytes = $transactionBody->serializeToString();
$sigMap = SignatureMap::build($bodyBytes, [$senderKeyPair]);
$protoTransaction->setSigMap($sigMap->getProto());
$protoTransaction->setBodyBytes($bodyBytes);
return $protoTransaction;
}
public function getTransactionBody() {
return $this->mTransactionBody;
}
public function getFirstPublic() {
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
return $sigPairs[0]->getPubKey();
}
public function getId() {
return $this->mProtoTransaction->getId();
}
public function validate() {
$sigMap = $this->mProtoTransaction->getSigMap();
if(!$sigMap) {
$this->addError('Transaction', 'signature map is zero');
return false;
}
//var_dump($sigMap);
//die();
$sigPairs = $sigMap->getSigPair();
$bodyBytes = $this->mProtoTransaction->getBodyBytes();
if(!$sigPairs || count($sigPairs) < 1) {
$this->addError('Transaction::validate', 'no signature found');
return false;
}
// check signature(s)
foreach($sigPairs as $sigPair) {
//echo 'sig Pair: '; var_dump($sigPair); echo "<br>";
$pubkey = $sigPair->getPubKey();
$signature = $sigPair->getEd25519();
//echo "verify bodybytes: <br>" . bin2hex($bodyBytes) . '<br>';
if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) {
$this->addError('Transaction::validate', 'signature for key ' . bin2hex($pubkey) . ' isn\'t valid ' );
return false;
}
}
if(!$this->mTransactionBody->validate($sigPairs)) {
$this->addErrors($this->mTransactionBody->getErrors());
return false;
}
return true;
}
public function save()
{
$connection = ConnectionManager::get('default');
$connection->begin();
//id transaction_id signature pubkey
if (!$this->mTransactionBody->save($this->getFirstPublic(), $this->mProtoTransaction->getSigMap())) {
$this->addErrors($this->mTransactionBody->getErrors());
$connection->rollback();
return false;
}
// save transaction signatures
$transactionsSignaturesTable = TableRegistry::getTableLocator()->get('transaction_signatures');
$transactionId = $this->mTransactionBody->getTransactionID();
//signature pubkey
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
//echo "sigPairs: "; var_dump($sigPairs);
$signatureEntitys = [];
foreach($sigPairs as $sigPair) {
$signatureEntity = $transactionsSignaturesTable->newEntity();
$signatureEntity->transaction_id = $transactionId;
$signatureEntity->signature = $sigPair->getEd25519();
$signatureEntity->pubkey = $sigPair->getPubKey();
array_push($signatureEntitys, $signatureEntity);
}
//debug($signatureEntitys);
if(!$transactionsSignaturesTable->saveMany($signatureEntitys)) {
foreach($signatureEntitys as $entity) {
$errors = $entity->getErrors();
if(!$errors && count($errors) > 0) {
$pubkeyHex = bin2hex($entity->pubkey);
$this->addError('Transaction::save', 'error saving signature for pubkey: ' . $pubkeyHex . ', with errors: ' . json_encode($errors) );
}
}
$connection->rollback();
return false;
}
$connection->commit();
$this->mTransactionBody->getSpecificTransaction()->sendNotificationEmail($this->mTransactionBody->getMemo());
return true;
}
static public function fromTable($id)
{
$transactionsTable = TableRegistry::getTableLocator()->get('transactions');
$transactionEntry = $transactionsTable
->find('all')
->where(['id' => $id])
->contain([
'TransactionCreations',
'TransactionSendCoins',
'TransactionSignatures'])
->first();
//var_dump($transactionEntry->toArray());
$protoTransaction = new \Model\Messages\Gradido\Transaction();
$protoTransaction->setId($transactionEntry->id);
$recevied = new \Model\Messages\Gradido\TimestampSeconds();
$recevied->setSeconds($transactionEntry->received->getTimestamp());
$protoTransaction->setReceived($recevied);
$sigMap = SignatureMap::fromEntity($transactionEntry->transaction_signatures);
$protoTransaction->setSigMap($sigMap->getProto());
//echo "sig map: check<br>";
$protoTransaction->setTxHash(stream_get_contents($transactionEntry->tx_hash));
$body = TransactionBody::fromEntity($transactionEntry->memo, $transactionEntry);
if(is_array($body)) {
return ['state' => 'error', 'msg' => 'error creating body transaction', 'details' => $body];
}
// validate signatures
$sigPairs = $sigMap->getProto()->getSigPair();
if(!$sigPairs || count($sigPairs) < 1) {
return ['state' => 'error', 'msg' => 'error no signatures found'];
}
//echo "verify bodybytes: <br>" . bin2hex($bodyBytes) . '<br>';
$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 "<br>";
$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;
}
}

View File

@ -1,122 +1,122 @@
<?php
namespace Model\Transactions;
use Cake\ORM\TableRegistry;
class TransactionBase {
private $errors = [];
static $tables = [];
public function getErrors() {
return $this->errors;
}
public function addError($functionName, $errorName) {
array_push($this->errors, [$functionName => $errorName]);
}
public function addErrors($errors) {
$this->errors = array_merge($this->errors, $errors);
}
public function hasErrors() {
return count($this->errors) > 0;
}
public static function getTable($tableName) {
if(!isset(self::$tables[$tableName])) {
self::$tables[$tableName] = TableRegistry::getTableLocator()->get($tableName);
}
return self::$tables[$tableName];
}
protected function getStateUserId($publicKey) {
$stateUsersTable = self::getTable('state_users');
$stateUser = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $publicKey])->first();
if($stateUser) {
return $stateUser->id;
}
// create new entry
$stateUserEntity = $stateUsersTable->newEntity();
$stateUserEntity->public_key = $publicKey;
if($stateUsersTable->save($stateUserEntity)) {
return $stateUserEntity->id;
} else {
$this->addError('TransactionBase::getStateUserId', 'error saving new state user with error: ' . json_encode($stateUserEntity->getErrors()));
}
return NULL;
}
protected function getStateUser($id) {
$stateUsersTable = self::getTable('state_users');
$stateUser = $stateUsersTable->get($id);
if($stateUser) {
return $stateUser;
}
return NULL;
}
protected function updateStateBalance($stateUserId, $addAmountCent, $recordDate) {
$finalBalance = 0;
$stateBalancesTable = self::getTable('stateBalances');
$stateBalanceQuery = $stateBalancesTable
->find('all')
->select(['amount', 'id'])
->contain(false)
->where(['state_user_id' => $stateUserId]);//->first();
//debug($stateBalanceQuery);
if($stateBalanceQuery->count() > 0) {
$stateBalanceEntry = $stateBalanceQuery->first();
$stateBalanceEntry->amount = $stateBalanceEntry->partDecay($recordDate) + $addAmountCent;
$stateBalanceEntry->amount += $addAmountCent;
} else {
$stateBalanceEntry = $stateBalancesTable->newEntity();
$stateBalanceEntry->state_user_id = $stateUserId;
$stateBalanceEntry->amount = $addAmountCent;
}
$stateBalanceEntry->record_date = $recordDate;
$finalBalance = $stateBalanceEntry->amount;
//echo "\ntry to save: "; var_dump($stateBalanceEntry); echo "\n";
if(!$stateBalancesTable->save($stateBalanceEntry)) {
$errors = $stateBalanceEntry->getErrors();
$this->addError('TransactionBase::updateStateBalance', 'error saving state balance with: ' . json_encode($errors));
return false;
}
return $finalBalance;
}
protected function addStateUserTransaction($stateUserId, $transactionId, $transactionTypeId, $balance) {
$stateUserTransactionTable = self::getTable('state_user_transactions');
$stateUserTransactions = $stateUserTransactionTable
->find('all')
->where(['state_user_id' => $stateUserId])
->order(['transaction_id DESC']);
if($stateUserTransactions->count() > 0) {
$stateBalanceTable = self::getTable('state_balances');
$balance_entity = $stateBalanceTable->newEntity();
$balance_entity->amount = $stateUserTransactions->first()->balance;
$balance_entity->record_date = $stateUserTransactions->first()->balance_date;
$balance = $balance_entity->decay + $balance;
}
$entity = $stateUserTransactionTable->newEntity();
$entity->state_user_id = $stateUserId;
$entity->transaction_id = $transactionId;
$entity->transaction_type_id = $transactionTypeId;
$entity->balance = $balance;
if(!$stateUserTransactionTable->save($entity)) {
$errors = $entity->getErrors();
$this->addError('TransactionBase::addStateUserTransaction', 'error saving state user balance with: ' . json_encode($errors));
return false;
}
return true;
}
<?php
namespace Model\Transactions;
use Cake\ORM\TableRegistry;
class TransactionBase {
private $errors = [];
static $tables = [];
public function getErrors() {
return $this->errors;
}
public function addError($functionName, $errorName) {
array_push($this->errors, [$functionName => $errorName]);
}
public function addErrors($errors) {
$this->errors = array_merge($this->errors, $errors);
}
public function hasErrors() {
return count($this->errors) > 0;
}
public static function getTable($tableName) {
if(!isset(self::$tables[$tableName])) {
self::$tables[$tableName] = TableRegistry::getTableLocator()->get($tableName);
}
return self::$tables[$tableName];
}
protected function getStateUserId($publicKey) {
$stateUsersTable = self::getTable('state_users');
$stateUser = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $publicKey])->first();
if($stateUser) {
return $stateUser->id;
}
// create new entry
$stateUserEntity = $stateUsersTable->newEntity();
$stateUserEntity->public_key = $publicKey;
if($stateUsersTable->save($stateUserEntity)) {
return $stateUserEntity->id;
} else {
$this->addError('TransactionBase::getStateUserId', 'error saving new state user with error: ' . json_encode($stateUserEntity->getErrors()));
}
return NULL;
}
protected function getStateUser($id) {
$stateUsersTable = self::getTable('state_users');
$stateUser = $stateUsersTable->get($id);
if($stateUser) {
return $stateUser;
}
return NULL;
}
protected function updateStateBalance($stateUserId, $addAmountCent, $recordDate) {
$finalBalance = 0;
$stateBalancesTable = self::getTable('stateBalances');
$stateBalanceQuery = $stateBalancesTable
->find('all')
->select(['amount', 'id'])
->contain(false)
->where(['state_user_id' => $stateUserId]);//->first();
//debug($stateBalanceQuery);
if($stateBalanceQuery->count() > 0) {
$stateBalanceEntry = $stateBalanceQuery->first();
$stateBalanceEntry->amount = $stateBalanceEntry->partDecay($recordDate) + $addAmountCent;
$stateBalanceEntry->amount += $addAmountCent;
} else {
$stateBalanceEntry = $stateBalancesTable->newEntity();
$stateBalanceEntry->state_user_id = $stateUserId;
$stateBalanceEntry->amount = $addAmountCent;
}
$stateBalanceEntry->record_date = $recordDate;
$finalBalance = $stateBalanceEntry->amount;
//echo "\ntry to save: "; var_dump($stateBalanceEntry); echo "\n";
if(!$stateBalancesTable->save($stateBalanceEntry)) {
$errors = $stateBalanceEntry->getErrors();
$this->addError('TransactionBase::updateStateBalance', 'error saving state balance with: ' . json_encode($errors));
return false;
}
return $finalBalance;
}
protected function addStateUserTransaction($stateUserId, $transactionId, $transactionTypeId, $balance) {
$stateUserTransactionTable = self::getTable('state_user_transactions');
$stateUserTransactions = $stateUserTransactionTable
->find('all')
->where(['state_user_id' => $stateUserId])
->order(['transaction_id DESC']);
if($stateUserTransactions->count() > 0) {
$stateBalanceTable = self::getTable('state_balances');
$balance_entity = $stateBalanceTable->newEntity();
$balance_entity->amount = $stateUserTransactions->first()->balance;
$balance_entity->record_date = $stateUserTransactions->first()->balance_date;
$balance = $balance_entity->decay + $balance;
}
$entity = $stateUserTransactionTable->newEntity();
$entity->state_user_id = $stateUserId;
$entity->transaction_id = $transactionId;
$entity->transaction_type_id = $transactionTypeId;
$entity->balance = $balance;
if(!$stateUserTransactionTable->save($entity)) {
$errors = $entity->getErrors();
$this->addError('TransactionBase::addStateUserTransaction', 'error saving state user balance with: ' . json_encode($errors));
return false;
}
return true;
}
}

View File

@ -1,149 +1,149 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$this->assign('title', __('Kontoübersicht'));
$header = '<h1>' . __('Aktueller Kontostand: ') . '</h1>' .
'<h1>' . $this->element('printGradido', ['number' => $balance]) . '</h1>';
if($gdtSum > 0) {
$header .= '<h1>'.$this->Html->link(
$this->element('printGDT', ['number' => $gdtSum]),
['action' => 'overview_gdt'],
['escape' => false]
).'</h1>';
}
$this->assign('header', $header);
//var_dump($transactions);
?>
<?php if($transactionExecutingCount > 0) : ?>
<div id="transaction-execute-display" class="">
</div>
<?php endif; ?>
<div class="content-list">
<p class="content-list-title">Überweisungen</p>
<div class="content-list-table">
<div class="row">
<div class="cell header-cell c4"><?= __('Absender') . ' / ' . ('Empfänger') ?></div>
<div class="cell header-cell c0"><?= __('Verwendungszweck') ?></div>
<div class="cell header-cell c4"><?= __('Datum') ?></div>
<div class="cell header-cell c3"><?= __('Betrag') ?></div>
<div class="cell header-cell c2" title="<?= __('Transaktions Nr.') ?>"><?= __('Nr') ?></div>
</div>
<?php foreach($transactions as $transaction):
$send = $transaction['type'] == 'send';
$balance = $transaction['balance'];
$memoShort = $transaction['memo'];
if(strlen($memoShort) > 30) {
$memoShort = substr($memoShort, 0, 30) . '...';
}
$cellColorClass = 'success-color';
if($send) {
$balance = -$balance;
$cellColorClass = 'alert-color';
} else if($transaction['type'] == 'creation') {
$cellColorClass = 'orange-color';
}
?>
<div class="row">
<div class="cell c4">
<?= $this->Html->image('50x50.png', ['class' => 'profile-img', 'alt' => 'profile image']) ?>
<div>
<?php if(isset($transaction['email']) && $transaction['email'] != ''): ?>
<a href="mailto:<?= $transaction['email'] ?>" title="<?= $transaction['email'] ?>">
<small class="tx-email"><?= $transaction['name'] ?></small>
</a>
<?php else : ?>
<small class="tx-email"><?= $transaction['name'] ?></small>
<?php endif; ?>
<!-- noch ungeklärt - icon ist nicht aligned -->
<div class="cell-icon <?= $cellColorClass ?>">
<?php if($transaction['type'] == 'creation') : ?>
<i class="material-icons-outlined orange-color">redeem</i>
<!-- insights / redeem -->
<?= __('Geschöpft')?>
<?php elseif($transaction['type'] == 'send') : ?>
<i class="material-icons-outlined">arrow_back</i>
<?= __('Gesendet') ?>
<?php elseif($transaction['type'] == 'receive') : ?>
<i class="material-icons-outlined">arrow_forward</i>
<?= __('Empfangen') ?>
<?php endif; ?>
</div>
</div>
</div>
<div class="cell c0" data-toggle="tooltip" data-placement="bottom" title="<?= $transaction['memo'] ?>">
<?php if(strlen($transaction['memo']) > 30): ?>
<?= substr($memoShort, 0, 30) . '...' ?>
<?php else : ?>
<?= $transaction['memo'] ?>
<?php endif;?>
</div>
<div class="cell c4"><?= $transaction['date']->nice() ?></div>
<div class="cell c3"><?= $this->element('printGradido', ['number' => $balance]) ?></div>
<div class="cell c2">
<?= $transaction['transaction_id'] ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!--<a class="border-top px-3 py-2 d-block text-gray" href="#"><small class="font-weight-medium"><i class="mdi mdi-chevron-down mr-2"></i>View All Order History</small></a>-->
<!--?= $this->Html->css(['gdt.css']) ?-->
<?php if($transactionExecutingCount > 0) : ?>
<script type="text/javascript">
//function getJson(basisUrl, method, successFunction, errorFunction, timeoutFunction)
g_transactionExecutionCount = <?= $transactionExecutingCount ?>;
function updateTransactionExecutingDisplay(count) {
var display = document.getElementById('transaction-execute-display');
display.innerHTML = count + " ";
if(count == 1) {
display.innerHTML += "<?= __('Laufende Transaktion') ?>";
} else {
display.innerHTML += "<?= __('Laufende Transaktionen') ?>";
}
display.innerHTML += '&nbsp;<div class="spinner-border text-light spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>';
}
function checkTransactionExecuting() {
getJson('<?= $this->Url->build(["controller" => "JsonRequestHandler"]);?>', 'getRunningUserTasks',
// success
function(json) {
if(json.state === 'success') {
var newCount = 0;
if(json.data.runningTasks["sign transaction"] != undefined) {
newCount = json.data.runningTasks["sign transaction"];
}
if(newCount != g_transactionExecutionCount) {
g_transactionExecutionCount = newCount;
location.reload();
//updateTransactionExecutingDisplay(g_transactionExecutionCount);
} else {
setTimeout(checkTransactionExecuting, 100);
}
}
},
// error
function(e) {
},
// timeout
function(e) {
}
)
}
(function(document, window, domIsReady, undefined) {
domIsReady(function() {
updateTransactionExecutingDisplay(g_transactionExecutionCount);
setTimeout(checkTransactionExecuting, 100);
//setInterval(checkTransactionExecuting, 100);
});
})(document, window, domIsReady);
</script>
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$this->assign('title', __('Kontoübersicht'));
$header = '<h1>' . __('Aktueller Kontostand: ') . '</h1>' .
'<h1>' . $this->element('printGradido', ['number' => $balance]) . '</h1>';
if($gdtSum > 0) {
$header .= '<h1>'.$this->Html->link(
$this->element('printGDT', ['number' => $gdtSum]),
['action' => 'overview_gdt'],
['escape' => false]
).'</h1>';
}
$this->assign('header', $header);
//var_dump($transactions);
?>
<?php if($transactionExecutingCount > 0) : ?>
<div id="transaction-execute-display" class="">
</div>
<?php endif; ?>
<div class="content-list">
<p class="content-list-title">Überweisungen</p>
<div class="content-list-table">
<div class="row">
<div class="cell header-cell c4"><?= __('Absender') . ' / ' . ('Empfänger') ?></div>
<div class="cell header-cell c0"><?= __('Verwendungszweck') ?></div>
<div class="cell header-cell c4"><?= __('Datum') ?></div>
<div class="cell header-cell c3"><?= __('Betrag') ?></div>
<div class="cell header-cell c2" title="<?= __('Transaktions Nr.') ?>"><?= __('Nr') ?></div>
</div>
<?php foreach($transactions as $transaction):
$send = $transaction['type'] == 'send';
$balance = $transaction['balance'];
$memoShort = $transaction['memo'];
if(strlen($memoShort) > 30) {
$memoShort = substr($memoShort, 0, 30) . '...';
}
$cellColorClass = 'success-color';
if($send) {
$balance = -$balance;
$cellColorClass = 'alert-color';
} else if($transaction['type'] == 'creation') {
$cellColorClass = 'orange-color';
}
?>
<div class="row">
<div class="cell c4">
<?= $this->Html->image('50x50.png', ['class' => 'profile-img', 'alt' => 'profile image']) ?>
<div>
<?php if(isset($transaction['email']) && $transaction['email'] != ''): ?>
<a href="mailto:<?= $transaction['email'] ?>" title="<?= $transaction['email'] ?>">
<small class="tx-email"><?= $transaction['name'] ?></small>
</a>
<?php else : ?>
<small class="tx-email"><?= $transaction['name'] ?></small>
<?php endif; ?>
<!-- noch ungeklärt - icon ist nicht aligned -->
<div class="cell-icon <?= $cellColorClass ?>">
<?php if($transaction['type'] == 'creation') : ?>
<i class="material-icons-outlined orange-color">redeem</i>
<!-- insights / redeem -->
<?= __('Geschöpft')?>
<?php elseif($transaction['type'] == 'send') : ?>
<i class="material-icons-outlined">arrow_back</i>
<?= __('Gesendet') ?>
<?php elseif($transaction['type'] == 'receive') : ?>
<i class="material-icons-outlined">arrow_forward</i>
<?= __('Empfangen') ?>
<?php endif; ?>
</div>
</div>
</div>
<div class="cell c0" data-toggle="tooltip" data-placement="bottom" title="<?= $transaction['memo'] ?>">
<?php if(strlen($transaction['memo']) > 30): ?>
<?= substr($memoShort, 0, 30) . '...' ?>
<?php else : ?>
<?= $transaction['memo'] ?>
<?php endif;?>
</div>
<div class="cell c4"><?= $transaction['date']->nice() ?></div>
<div class="cell c3"><?= $this->element('printGradido', ['number' => $balance]) ?></div>
<div class="cell c2">
<?= $transaction['transaction_id'] ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!--<a class="border-top px-3 py-2 d-block text-gray" href="#"><small class="font-weight-medium"><i class="mdi mdi-chevron-down mr-2"></i>View All Order History</small></a>-->
<!--?= $this->Html->css(['gdt.css']) ?-->
<?php if($transactionExecutingCount > 0) : ?>
<script type="text/javascript">
//function getJson(basisUrl, method, successFunction, errorFunction, timeoutFunction)
g_transactionExecutionCount = <?= $transactionExecutingCount ?>;
function updateTransactionExecutingDisplay(count) {
var display = document.getElementById('transaction-execute-display');
display.innerHTML = count + " ";
if(count == 1) {
display.innerHTML += "<?= __('Laufende Transaktion') ?>";
} else {
display.innerHTML += "<?= __('Laufende Transaktionen') ?>";
}
display.innerHTML += '&nbsp;<div class="spinner-border text-light spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>';
}
function checkTransactionExecuting() {
getJson('<?= $this->Url->build(["controller" => "JsonRequestHandler"]);?>', 'getRunningUserTasks',
// success
function(json) {
if(json.state === 'success') {
var newCount = 0;
if(json.data.runningTasks["sign transaction"] != undefined) {
newCount = json.data.runningTasks["sign transaction"];
}
if(newCount != g_transactionExecutionCount) {
g_transactionExecutionCount = newCount;
location.reload();
//updateTransactionExecutingDisplay(g_transactionExecutionCount);
} else {
setTimeout(checkTransactionExecuting, 100);
}
}
},
// error
function(e) {
},
// timeout
function(e) {
}
)
}
(function(document, window, domIsReady, undefined) {
domIsReady(function() {
updateTransactionExecutingDisplay(g_transactionExecutionCount);
setTimeout(checkTransactionExecuting, 100);
//setInterval(checkTransactionExecuting, 100);
});
})(document, window, domIsReady);
</script>
<?php endif; ?>

View File

@ -1,29 +1,29 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>
<div class="grd_container_small">
<table>
<thead>
<tr>
<th>first name</th><th>last name</th><th>email</th><th>identHash</th><th>Public key hex
</tr>
</thead>
<tbody>
<?php foreach($stateUsers as $user) :?>
<tr>
<td><?= $user->first_name ?></td>
<td><?= $user->last_name ?></td>
<td><?= $user->email ?></td>
<td><?= $user->identHash ?></td>
<td><?= bin2hex(stream_get_contents($user->public_key)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>
<div class="grd_container_small">
<table>
<thead>
<tr>
<th>first name</th><th>last name</th><th>email</th><th>identHash</th><th>Public key hex
</tr>
</thead>
<tbody>
<?php foreach($stateUsers as $user) :?>
<tr>
<td><?= $user->first_name ?></td>
<td><?= $user->last_name ?></td>
<td><?= $user->email ?></td>
<td><?= $user->identHash ?></td>
<td><?= bin2hex(stream_get_contents($user->public_key)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

View File

@ -1,31 +1,31 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$address_options = [];//__('Selbst eingeben:')];
foreach($receiverProposal as $i => $receiver) {
//var_dump($receiver);
array_push($address_options, [
'text' => $receiver['name'],
'value' => $i+1,
'title' => $receiver['key']
]);
}
$this->assign('title', __('Schöpfungstransaktion'));
?>
<div class="grd_container_small">
<?= $this->Form->create($creationForm) ?>
<fieldset>
<?= $this->Form->control('memo'); ?>
<?= $this->Form->control('amount'); ?>
<?= $this->Form->control('receiver', ['options' => $address_options]); ?>
<!--<?= $this->Form->control('receiver_pubkey_hex', []) ?>-->
</fieldset>
<?= $this->Form->button(__('Transaktion(en) abschließen'), ['name' => 'next', 'class' => 'grd-form-bn grd-form-bn-succeed grd_clickable grd-width-200']) ?>
<?= $this->Form->button(__('Weitere Transaktion erstellen'), ['name' => 'add', 'class' => 'grd-form-bn grd_clickable grd-width-200']) ?>
<?= $this->Form->end() ?>
</div>
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$address_options = [];//__('Selbst eingeben:')];
foreach($receiverProposal as $i => $receiver) {
//var_dump($receiver);
array_push($address_options, [
'text' => $receiver['name'],
'value' => $i+1,
'title' => $receiver['key']
]);
}
$this->assign('title', __('Schöpfungstransaktion'));
?>
<div class="grd_container_small">
<?= $this->Form->create($creationForm) ?>
<fieldset>
<?= $this->Form->control('memo'); ?>
<?= $this->Form->control('amount'); ?>
<?= $this->Form->control('receiver', ['options' => $address_options]); ?>
<!--<?= $this->Form->control('receiver_pubkey_hex', []) ?>-->
</fieldset>
<?= $this->Form->button(__('Transaktion(en) abschließen'), ['name' => 'next', 'class' => 'grd-form-bn grd-form-bn-succeed grd_clickable grd-width-200']) ?>
<?= $this->Form->button(__('Weitere Transaktion erstellen'), ['name' => 'add', 'class' => 'grd-form-bn grd_clickable grd-width-200']) ?>
<?= $this->Form->end() ?>
</div>

View File

@ -1,46 +1,46 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>
<div class="transactions form large-9 medium-8 columns content">
<h1>Synchronize state_user_transactions with transactions</h1>
<p>transactions count: <?= $count1 ?></p>
<p>state_user_transaction count: <?= $count2 ?></p>
<p>Missing count: <?= count($missing_transactions); ?></p>
<p>First 10 Missing ids: </p>
<p><?php
foreach($missing_transactions as $i => $id) {
if($i > 10) break;
if($i > 0) echo ', ';
echo $id['id'];
} ?></p>
<?php if(isset($entities) && isset($results)) : ?>
<h2>Synchronize errors: </h2>
<ul>
<?php
$succeed = 0;
//var_dump($results);
if($results) :
foreach($results as $i => $result) :
if(false != $result) {
$succeed++;
continue;
}
?>
<li>Error saving entity: <?= json_encode($entities[$i]) ?> with error: <?= json_encode($entities[$i]->getErrors()) ?></li>
<?php endforeach; ?>
<?php endif; ?>
<li><success>Succeed: <?= $succeed ?></success></li>
</ul>
<?php endif; ?>
<?= $this->Form->create() ?>
<?= $this->Form->button(__('Synchronize')) ?>
<?= $this->Form->end() ?>
</div>
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>
<div class="transactions form large-9 medium-8 columns content">
<h1>Synchronize state_user_transactions with transactions</h1>
<p>transactions count: <?= $count1 ?></p>
<p>state_user_transaction count: <?= $count2 ?></p>
<p>Missing count: <?= count($missing_transactions); ?></p>
<p>First 10 Missing ids: </p>
<p><?php
foreach($missing_transactions as $i => $id) {
if($i > 10) break;
if($i > 0) echo ', ';
echo $id['id'];
} ?></p>
<?php if(isset($entities) && isset($results)) : ?>
<h2>Synchronize errors: </h2>
<ul>
<?php
$succeed = 0;
//var_dump($results);
if($results) :
foreach($results as $i => $result) :
if(false != $result) {
$succeed++;
continue;
}
?>
<li>Error saving entity: <?= json_encode($entities[$i]) ?> with error: <?= json_encode($entities[$i]->getErrors()) ?></li>
<?php endforeach; ?>
<?php endif; ?>
<li><success>Succeed: <?= $succeed ?></success></li>
</ul>
<?php endif; ?>
<?= $this->Form->create() ?>
<?= $this->Form->button(__('Synchronize')) ?>
<?= $this->Form->end() ?>
</div>

View File

@ -1,46 +1,46 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\AppController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\DashboardController Test Case
*
* @uses \App\Controller\DashboardController
*/
class AppControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.StateBalances'
];
public function setUp()
{
parent::setUp();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->session(['StateUser.id' => 1]);
$this->get('/');
$this->assertSession(1200, 'StateUser.balance');
//$this->markTestIncomplete('Not implemented yet.');
}
}
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\AppController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\DashboardController Test Case
*
* @uses \App\Controller\DashboardController
*/
class AppControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.StateBalances'
];
public function setUp()
{
parent::setUp();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->session(['StateUser.id' => 1]);
$this->get('/');
$this->assertSession(1200, 'StateUser.balance');
//$this->markTestIncomplete('Not implemented yet.');
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff