|
|
@ -356,12 +356,6 @@ class Room |
|
|
|
$message = $mention . PHP_EOL . $message; |
|
|
|
$message = $mention . PHP_EOL . $message; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validate final message length |
|
|
|
|
|
|
|
if (mb_strlen($message) < 1 || mb_strlen($message) > 3072) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cleanup session |
|
|
|
// Cleanup session |
|
|
|
$this->_memory->delete( |
|
|
|
$this->_memory->delete( |
|
|
|
$session |
|
|
|
$session |
|
|
@ -404,7 +398,11 @@ class Room |
|
|
|
$this->_config->kevachat->post->pool->account |
|
|
|
$this->_config->kevachat->post->pool->account |
|
|
|
), |
|
|
|
), |
|
|
|
':namespace' => $namespace, |
|
|
|
':namespace' => $namespace, |
|
|
|
':key' => 'anon', |
|
|
|
':key' => sprintf( |
|
|
|
|
|
|
|
'%d@%s', |
|
|
|
|
|
|
|
time(), |
|
|
|
|
|
|
|
'anon' |
|
|
|
|
|
|
|
), |
|
|
|
':value' => $message |
|
|
|
':value' => $message |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
@ -428,7 +426,11 @@ class Room |
|
|
|
// Make blockchain record |
|
|
|
// Make blockchain record |
|
|
|
return $this->_kevacoin->kevaPut( |
|
|
|
return $this->_kevacoin->kevaPut( |
|
|
|
$namespace, |
|
|
|
$namespace, |
|
|
|
'anon', |
|
|
|
sprintf( |
|
|
|
|
|
|
|
'%d@%s', |
|
|
|
|
|
|
|
time(), |
|
|
|
|
|
|
|
'anon' |
|
|
|
|
|
|
|
), |
|
|
|
$message |
|
|
|
$message |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -524,21 +526,6 @@ class Room |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Skip values with meta keys |
|
|
|
|
|
|
|
if (str_starts_with($data['key'], '_')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Legacy key format support (protocol v1 contain timestamp in prefix) |
|
|
|
|
|
|
|
if (preg_match('/^([\d]+)@([A-z0-9\.\:\[\]]+)/', $data['key'], $matches)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!empty($matches[2])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$data['key'] = $matches[2]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate value format allowed in settings |
|
|
|
// Validate value format allowed in settings |
|
|
|
if (!preg_match((string) $this->_config->kevachat->post->value->regex, $data['value'])) |
|
|
|
if (!preg_match((string) $this->_config->kevachat->post->value->regex, $data['value'])) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -546,22 +533,19 @@ class Room |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validate key format allowed in settings |
|
|
|
// Validate key format allowed in settings |
|
|
|
if (!preg_match($this->_config->kevachat->post->key->regex, $data['key'])) |
|
|
|
if (!preg_match($this->_config->kevachat->post->key->regex, $data['key'], $key)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get time from raw transaction |
|
|
|
// Validate timestamp@username |
|
|
|
if (!$transaction = $this->_kevacoin->getRawTransaction($data['txid'])) |
|
|
|
if (empty($key[1]) || empty($key[2])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make sure time available |
|
|
|
// Return timestamp |
|
|
|
if (!$time = $transaction['time']) |
|
|
|
$time = (int) $key[1]; |
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Is raw field request |
|
|
|
// Is raw field request |
|
|
|
if ($field) |
|
|
|
if ($field) |
|
|
@ -680,11 +664,11 @@ class Room |
|
|
|
[ |
|
|
|
[ |
|
|
|
// time |
|
|
|
// time |
|
|
|
$this->_ago( |
|
|
|
$this->_ago( |
|
|
|
$transaction['time'] |
|
|
|
$key[1] |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
// author |
|
|
|
// author |
|
|
|
$data['key'], |
|
|
|
$key[2], |
|
|
|
|
|
|
|
|
|
|
|
// quote |
|
|
|
// quote |
|
|
|
$quote, |
|
|
|
$quote, |
|
|
|