added missing files
This commit is contained in:
@@ -4,23 +4,18 @@ try {
|
||||
$user = $db->real_escape_string($_REQUEST['user']);
|
||||
$pubkey = $db->real_escape_string($_REQUEST['pubkey']);
|
||||
$pgp = gnupg_init();
|
||||
if (!$pgp) {
|
||||
echo json_encode(array('success' => false, 'txt' => "pgp on server failed"));
|
||||
if (!$pgp) error("pgp on server failed");
|
||||
$verify = gnupg_import($pgp, $_REQUEST['pubkey']);
|
||||
if (!$verify) error("wrong identity");
|
||||
$q = $db->query("select * from user where name='$user' and pubkey='$pubkey';");
|
||||
if ($q->num_rows==1) {
|
||||
success("user verified");
|
||||
} elseif ($q->num_rows==0) {
|
||||
$q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');");
|
||||
if (!q) error("creation of user failed");
|
||||
success("user created");
|
||||
} else {
|
||||
$verify = gnupg_import($pgp, $_REQUEST['pubkey']);
|
||||
if (!$verify) {
|
||||
echo json_encode(array('success' => false, 'txt' => "wrong identity"));
|
||||
} else {
|
||||
$q = $db->query("select * from user where name='$user' and pubkey='$pubkey';");
|
||||
if ($q->num_rows==1) {
|
||||
echo json_encode(array('success' => true, 'txt' => "user verified"));
|
||||
} elseif ($q->num_rows==0) {
|
||||
$q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');");
|
||||
echo json_encode(array('success' => true, 'txt' => "user created"));
|
||||
} else {
|
||||
echo json_encode(array('success' => false, 'txt' => "server database defect"));
|
||||
}
|
||||
}
|
||||
error("server database defect");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(array('success' => false, 'txt' => "login failed"));
|
||||
|
@@ -6,10 +6,15 @@
|
||||
EXTRA_DIST = ${www_DATA}
|
||||
|
||||
wwwdir = ${pkgdatadir}/html
|
||||
www_DATA = index.html chat.html newuser.html \
|
||||
safechat.js jquery.js openpgp.js jquery.cssemoticons.js \
|
||||
safechat.css jquery.cssemoticons.css \
|
||||
checknewuser.php get.php login.php messagetable.php \
|
||||
pubkey.php send.php usertable.php
|
||||
www_DATA = index.html chat.html newuser.html safechat.js jquery.js \
|
||||
openpgp.js jquery.cssemoticons.js safechat.css \
|
||||
jquery.cssemoticons.css checknewuser.php get.php login.php \
|
||||
messagetable.php pubkey.php send.php usertable.php \
|
||||
abort.svg A-Tone-His_Self-1266414414.mp3 attachment.svg \
|
||||
audio.svg chat-rodrigo-angleton.svg \
|
||||
Checkout-Scanner-Beep-SoundBible.com-593325210-by-Mike-Koenig.mp3 \
|
||||
envelope.svg functions.php menu.svg pfeil.svg photo.png \
|
||||
photo.svg safechat-rodrigo-angleton.svg safe-mimooh.svg \
|
||||
send.svg update-messages.js video.png video.svg
|
||||
|
||||
MAINTAINERCLEANFILES = makefile.in
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once("functions.php");
|
||||
mysqli_report(MYSQLI_REPORT_STRICT);
|
||||
try {
|
||||
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);
|
||||
|
@@ -161,14 +161,56 @@ function clearmessage() {
|
||||
|
||||
function attachments(files, id) {
|
||||
if (files) files.forEach(function(file) {
|
||||
if (file.content.length<1000000) {
|
||||
if (file.content.length<100000) {
|
||||
var img = document.createElement('img');
|
||||
img.src = 'data:'+file.type+';base64,' + file.content;
|
||||
img.src = file.content;
|
||||
$(id).append(img);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fileupload(evt) {
|
||||
if (!window.FileReader) return error("your browser dows not support file upload", true);
|
||||
for (var i=0, f; f=evt.target.files[i]; ++i) {
|
||||
var file = f;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(evt) {
|
||||
if (evt.target.error) return error("error reading file", true);
|
||||
if (evt.target.readyState==0) return notice("waiting for data ...");
|
||||
if (evt.target.readyState==1) return notice("loading data ...");
|
||||
if (!file.type.match('^image/')) return error(file.name+": not an image", true);
|
||||
var img = document.createElement("img");
|
||||
img.onload = function() {
|
||||
var MAX = 400;
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
if (width > MAX) {
|
||||
height *= MAX / width;
|
||||
width = MAX;
|
||||
}
|
||||
if (height > MAX) {
|
||||
width *= MAX / height;
|
||||
height = MAX;
|
||||
}
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
img.onload = function() {
|
||||
filecontent.push({type: file.type, content: img.src});
|
||||
$("#preview").append(img);
|
||||
success('image of type '+file.type+' is ready to be sent');
|
||||
}
|
||||
img.src = canvas.toDataURL(file.type);
|
||||
}
|
||||
img.src=evt.target.result;
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function fileupload(evt) {
|
||||
if (!window.FileReader)
|
||||
return error("your browser dows not support file upload", true);
|
||||
@@ -193,6 +235,7 @@ function fileupload(evt) {
|
||||
reader.readAsBinaryString(file);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function setreceiver(name) {
|
||||
$("#recv").val(name);
|
||||
|
@@ -4,31 +4,22 @@ try {
|
||||
$user = $db->real_escape_string($_REQUEST['user']);
|
||||
$msg = $db->real_escape_string($_REQUEST['msg']);
|
||||
$pgp = gnupg_init();
|
||||
if (!$pgp) {
|
||||
echo json_encode(array('success' => false, 'txt' => "pgp on server failed"));
|
||||
} else {
|
||||
$q = $db->query("select pubkey from user where name='$user';");
|
||||
if (!$q || $q->num_rows!=1) {
|
||||
echo json_encode(array('success' => false, 'txt' => "user not found on server"));
|
||||
} else {
|
||||
$pubkey = gnupg_import($pgp, $q->fetch_row()[0]);
|
||||
if (!$pubkey) {
|
||||
echo json_encode(array('success' => false, 'txt' => "wrong identity"));
|
||||
} else {
|
||||
require_once("messagetable.php");
|
||||
$q = $db->query("insert into message (user, msg) values ('$user', '$msg');");
|
||||
if ($q) {
|
||||
echo json_encode(array('success' => true, 'txt' => "message stored"));
|
||||
} else {
|
||||
error_log("Error storing message: ".$db->error);
|
||||
echo json_encode(array('success' => false, 'txt' => "storing message failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen($_REQUEST['msg'])>100000) error("message is too long");
|
||||
if (!$pgp) error("pgp on server failed");
|
||||
$q = $db->query("select pubkey from user where name='$user';");
|
||||
if (!$q || $q->num_rows!=1) error("user not found on server");
|
||||
$pubkey = gnupg_import($pgp, $q->fetch_row()[0]);
|
||||
if (!$pubkey) error("wrong identity");
|
||||
require_once("messagetable.php");
|
||||
$q = $db->query("insert into message (user, msg) values ('$user', '$msg');");
|
||||
if (!$q) {
|
||||
error_log("Error storing message: ".$db->error);
|
||||
error("storing message failed");
|
||||
}
|
||||
success("message stored");
|
||||
} catch (Exception $e) {
|
||||
error_log("Error storing message: ".$e->message);
|
||||
echo json_encode(array('success' => false, 'txt' => "storing message failed"));
|
||||
error("storing message failed");
|
||||
}
|
||||
|
||||
?>
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once("functions.php");
|
||||
mysqli_report(MYSQLI_REPORT_STRICT);
|
||||
try {
|
||||
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);
|
||||
|
Reference in New Issue
Block a user