added missing files

php
Marc Wäckerlin 10 years ago
parent ec0aa99323
commit d17175b421
  1. 14
      ChangeLog
  2. 17
      html/login.php
  3. 15
      html/makefile.am
  4. 1
      html/messagetable.php
  5. 47
      html/safechat.js
  6. 25
      html/send.php
  7. 1
      html/usertable.php

@ -1,3 +1,17 @@
2015-07-01 13:34 marc
* README: build need description
2015-07-01 13:08 marc
* ChangeLog, html/makefile.am: too much isn't good either
2015-07-01 11:45 marc
* html/chat-rodrigo-angleton.svg, html/makefile.am, html/menu.svg,
html/safe-mimooh.svg, html/safechat-rodrigo-angleton.svg: missing
files added
2015-07-01 00:08 marc 2015-07-01 00:08 marc
* html/abort.svg, html/audio.svg, html/envelope.svg, * html/abort.svg, html/audio.svg, html/envelope.svg,

@ -4,23 +4,18 @@ try {
$user = $db->real_escape_string($_REQUEST['user']); $user = $db->real_escape_string($_REQUEST['user']);
$pubkey = $db->real_escape_string($_REQUEST['pubkey']); $pubkey = $db->real_escape_string($_REQUEST['pubkey']);
$pgp = gnupg_init(); $pgp = gnupg_init();
if (!$pgp) { if (!$pgp) error("pgp on server failed");
echo json_encode(array('success' => false, 'txt' => "pgp on server failed"));
} else {
$verify = gnupg_import($pgp, $_REQUEST['pubkey']); $verify = gnupg_import($pgp, $_REQUEST['pubkey']);
if (!$verify) { if (!$verify) error("wrong identity");
echo json_encode(array('success' => false, 'txt' => "wrong identity"));
} else {
$q = $db->query("select * from user where name='$user' and pubkey='$pubkey';"); $q = $db->query("select * from user where name='$user' and pubkey='$pubkey';");
if ($q->num_rows==1) { if ($q->num_rows==1) {
echo json_encode(array('success' => true, 'txt' => "user verified")); success("user verified");
} elseif ($q->num_rows==0) { } elseif ($q->num_rows==0) {
$q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');"); $q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');");
echo json_encode(array('success' => true, 'txt' => "user created")); if (!q) error("creation of user failed");
success("user created");
} else { } else {
echo json_encode(array('success' => false, 'txt' => "server database defect")); error("server database defect");
}
}
} }
} catch (Exception $e) { } catch (Exception $e) {
echo json_encode(array('success' => false, 'txt' => "login failed")); echo json_encode(array('success' => false, 'txt' => "login failed"));

@ -6,10 +6,15 @@
EXTRA_DIST = ${www_DATA} EXTRA_DIST = ${www_DATA}
wwwdir = ${pkgdatadir}/html wwwdir = ${pkgdatadir}/html
www_DATA = index.html chat.html newuser.html \ www_DATA = index.html chat.html newuser.html safechat.js jquery.js \
safechat.js jquery.js openpgp.js jquery.cssemoticons.js \ openpgp.js jquery.cssemoticons.js safechat.css \
safechat.css jquery.cssemoticons.css \ jquery.cssemoticons.css checknewuser.php get.php login.php \
checknewuser.php get.php login.php messagetable.php \ messagetable.php pubkey.php send.php usertable.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 MAINTAINERCLEANFILES = makefile.in

@ -1,4 +1,5 @@
<?php <?php
require_once("functions.php");
mysqli_report(MYSQLI_REPORT_STRICT); mysqli_report(MYSQLI_REPORT_STRICT);
try { try {
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]); $db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);

@ -161,14 +161,56 @@ function clearmessage() {
function attachments(files, id) { function attachments(files, id) {
if (files) files.forEach(function(file) { if (files) files.forEach(function(file) {
if (file.content.length<1000000) { if (file.content.length<100000) {
var img = document.createElement('img'); var img = document.createElement('img');
img.src = 'data:'+file.type+';base64,' + file.content; img.src = file.content;
$(id).append(img); $(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) { function fileupload(evt) {
if (!window.FileReader) if (!window.FileReader)
return error("your browser dows not support file upload", true); return error("your browser dows not support file upload", true);
@ -193,6 +235,7 @@ function fileupload(evt) {
reader.readAsBinaryString(file); reader.readAsBinaryString(file);
} }
} }
*/
function setreceiver(name) { function setreceiver(name) {
$("#recv").val(name); $("#recv").val(name);

@ -4,31 +4,22 @@ try {
$user = $db->real_escape_string($_REQUEST['user']); $user = $db->real_escape_string($_REQUEST['user']);
$msg = $db->real_escape_string($_REQUEST['msg']); $msg = $db->real_escape_string($_REQUEST['msg']);
$pgp = gnupg_init(); $pgp = gnupg_init();
if (!$pgp) { if (strlen($_REQUEST['msg'])>100000) error("message is too long");
echo json_encode(array('success' => false, 'txt' => "pgp on server failed")); if (!$pgp) error("pgp on server failed");
} else {
$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) { if (!$q || $q->num_rows!=1) error("user not found on server");
echo json_encode(array('success' => false, 'txt' => "user not found on server"));
} else {
$pubkey = gnupg_import($pgp, $q->fetch_row()[0]); $pubkey = gnupg_import($pgp, $q->fetch_row()[0]);
if (!$pubkey) { if (!$pubkey) error("wrong identity");
echo json_encode(array('success' => false, 'txt' => "wrong identity"));
} else {
require_once("messagetable.php"); require_once("messagetable.php");
$q = $db->query("insert into message (user, msg) values ('$user', '$msg');"); $q = $db->query("insert into message (user, msg) values ('$user', '$msg');");
if ($q) { if (!$q) {
echo json_encode(array('success' => true, 'txt' => "message stored"));
} else {
error_log("Error storing message: ".$db->error); error_log("Error storing message: ".$db->error);
echo json_encode(array('success' => false, 'txt' => "storing message failed")); error("storing message failed");
}
}
}
} }
success("message stored");
} catch (Exception $e) { } catch (Exception $e) {
error_log("Error storing message: ".$e->message); 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 <?php
require_once("functions.php");
mysqli_report(MYSQLI_REPORT_STRICT); mysqli_report(MYSQLI_REPORT_STRICT);
try { try {
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]); $db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);

Loading…
Cancel
Save