|
|
@ -2,33 +2,30 @@ |
|
|
|
/*! @file |
|
|
|
/*! @file |
|
|
|
|
|
|
|
|
|
|
|
@id $Id$ |
|
|
|
@id $Id$ |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// 1 2 3 4 5 6 7 8 |
|
|
|
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890 |
|
|
|
|
|
|
|
|
|
|
|
@see @ref apisend |
|
|
|
/// Send a message to the server |
|
|
|
|
|
|
|
/** Server checks if user exists and has |
|
|
|
@page api |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@section apisend Send Message To Server |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
API-call send.php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Send a message to the server. Sever checks if user exists and has |
|
|
|
|
|
|
|
a valid public key. More test could be added later. |
|
|
|
a valid public key. More test could be added later. |
|
|
|
|
|
|
|
|
|
|
|
@param user The name of the user that send the message. |
|
|
|
@param $user The name of the user that send the message. |
|
|
|
|
|
|
|
|
|
|
|
@param msg The armored signed and encrypted message. There is a |
|
|
|
@param $msg The armored signed and encrypted message. There is a |
|
|
|
limit of 100000 bytes for the message. |
|
|
|
limit of 100000 bytes for the message. |
|
|
|
|
|
|
|
|
|
|
|
@return |
|
|
|
@return |
|
|
|
- success() if the message has been stored successfully |
|
|
|
- success() if the message has been stored successfully |
|
|
|
- error() in case of any error |
|
|
|
- error() in case of any error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api Send Message to Server |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
// 1 2 3 4 5 6 7 8 |
|
|
|
function send($user, $msg) { |
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890 |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
require_once("opendb.php"); |
|
|
|
require_once("opendb.php"); |
|
|
|
$user = $db->real_escape_string($_REQUEST['user']); |
|
|
|
$user = $db->real_escape_string($user); |
|
|
|
$msg = $db->real_escape_string($_REQUEST['msg']); |
|
|
|
$msg = $db->real_escape_string($msg); |
|
|
|
if (strlen($_REQUEST['msg'])>100000) error("message is too long"); |
|
|
|
if (strlen($_REQUEST['msg'])>100000) error("message is too long"); |
|
|
|
$q = $db->query("select pubkey from user where name='$user';"); |
|
|
|
$q = $db->query("select pubkey from user where name='$user';"); |
|
|
|
if (!$q || $q->num_rows!=1) error("user not found on server"); |
|
|
|
if (!$q || $q->num_rows!=1) error("user not found on server"); |
|
|
@ -44,5 +41,6 @@ try { |
|
|
|
error_log("Error storing message: ".$e->message); |
|
|
|
error_log("Error storing message: ".$e->message); |
|
|
|
error("storing message failed"); |
|
|
|
error("storing message failed"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
send($_REQUEST['user'], $_REQUEST['msg']); |
|
|
|
?> |
|
|
|
?> |