AUTHOR updated to new homepage

php
Marc Wäckerlin 9 years ago
parent 75e29bfbe3
commit f11d2c7c56
  1. 2
      AUTHORS
  2. 121
      ax_check_qt.m4
  3. 108
      ax_init_standard_project.m4
  4. 2
      bootstrap.sh
  5. 6
      configure.ac
  6. 2
      cordova/platforms/android/AndroidManifest.xml
  7. 2
      cordova/platforms/android/res/xml/config.xml
  8. 49
      html/functions.php
  9. 3
      html/login.php
  10. 8
      html/messagetable.php
  11. 5
      html/pubkey.php
  12. 37
      html/safechat.js
  13. 2
      html/send.php
  14. 8
      html/usertable.php
  15. 6
      makefile.am
  16. 8
      resolve-rpmbuilddeps.sh
  17. 60
      safechat.spec.in
  18. 11
      scripts/makefile.am

@ -1 +1 @@
Marc Wäckerlin (http://marc.waeckerlin.org) <marc@waeckerlin.org>
Marc Wäckerlin (https://marc.wäckerlin.ch) <marc@waeckerlin.org>

@ -1,10 +1,10 @@
# SYNOPSIS
#
# Check if a module exists:
# AX_CHECK_QT([qt_prefix], [list-of-qt-modules], [optional-modules])
# AX_CHECK_QT([qt_prefix], [list-of-qt-modules], [optional-modules] [flags])
#
# Abort if a module does not exist:
# AX_REQUIRE_QT([qt_prefix], [list-of-qt-modules], [optional-modules])
# AX_REQUIRE_QT([qt_prefix], [list-of-qt-modules], [optional-modules] [flags])
#
# DESCRIPTIONS
#
@ -35,6 +35,18 @@
# Optional list of more, optional modules, e.g. modules that
# exist only in Qt5, but not in Qt4, such as QtWidgets or
# QtWebKitWidgets
#
# flags
#
# Optional flages, space separated from this list:
#
# manualflags
#
# CXXFLAGS, CPPFLAGS and LIBS variables are not
# automatically expanded, but you need to add the
# qt_prefix_CXXFLAGS, qt_prefix_CPPFLAGS and qt_prefix_LIBS
# variables manually where you need them. This is useful,
# if some build targets need a feature and some don't.
AC_DEFUN([AX_CXX_QT_TOOL], [
@ -83,6 +95,7 @@ AC_DEFUN([AX_CXX_QT_TOOLS], [
AC_DEFUN([AX_CHECK_QT], [
qt_modules="$2"
qt_modules_optional="$3"
qt_flags="$4"
AX_CXX_QT_TOOLS
HAVE_$1=0
PKG_PROG_PKG_CONFIG
@ -91,17 +104,37 @@ AC_DEFUN([AX_CHECK_QT], [
AC_DEFINE([HAVE_$1])
QTDIR=$(${PKG_CONFIG} --variable=prefix Qt5Core)
QT_PLUGIN_PATH=${QTDIR}/share/qt5/plugins
CPPFLAGS+=" ${[$1]5_CFLAGS}"
MOC_FLAGS+=" -DHAVE_$1=1 ${[$1]5_CFLAGS}"
CXXFLAGS+=" ${[$1]5_CFLAGS}"
LIBS+=" ${[$1]5_LIBS}"
[$1]_CPPFLAGS="${[$1]5_CFLAGS}"
[$1]_CXXFLAGS="${[$1]5_CFLAGS}"
[$1]_LIBS="${[$1]5_LIBS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
CPPFLAGS+=" ${[$1]_CPPFLAGS}"
CXXFLAGS+=" ${[$1]_CXXFLAGS}"
LIBS+=" ${[$1]_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
PKG_REQUIREMENTS+=" ${qt_modules//Qt/Qt5}"
if test -n "${qt_modules_optional}"; then
PKG_CHECK_MODULES([$1]5_OPTIONAL, [${qt_modules_optional//Qt/Qt5}], [
CPPFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
MOC_FLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
CXXFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
LIBS+=" ${[$1]5_OPTIONAL_LIBS}"
[$1]_CPPFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
[$1]_CXXFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
[$1]_LIBS+=" ${[$1]5_OPTIONAL_LIBS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
CPPFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
CXXFLAGS+=" ${[$1]5_OPTIONAL_CFLAGS}"
LIBS+=" ${[$1]5_OPTIONAL_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
PKG_REQUIREMENTS+=" ${qt_modules_optional//Qt/Qt5}"
], [
AC_MSG_NOTICE([Not found: ${qt_modules_optional//Qt/Qt5}])
@ -113,17 +146,36 @@ AC_DEFUN([AX_CHECK_QT], [
AC_DEFINE([HAVE_$1])
QTDIR=$(${PKG_CONFIG} --variable=prefix QtCore)
QT_PLUGIN_PATH=${QTDIR}/share/qt/plugins
CPPFLAGS+=" ${$1_CFLAGS}"
MOC_FLAGS+=" -DHAVE_$1=1 ${$1_CFLAGS}"
CXXFLAGS+=" ${$1_CFLAGS}"
LIBS+=" ${$1_LIBS}"
[$1]_CPPFLAGS="${[$1]_CFLAGS}"
[$1]_CXXFLAGS="${[$1]_CFLAGS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
CPPFLAGS+=" ${[$1]_CPPFLAGS}"
CXXFLAGS+=" ${[$1]_CXXFLAGS}"
LIBS+=" ${[$1]_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
PKG_REQUIREMENTS+=" ${qt_modules}"
if test -n "$3"; then
PKG_CHECK_MODULES($1_OPTIONAL, [${qt_modules_optional}], [
CPPFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
MOC_FLAGS+=" ${$1_OPTIONAL_CFLAGS}"
CXXFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
LIBS+=" ${$1_OPTIONAL_LIBS}"
MOC_FLAGS+="${$1_OPTIONAL_CFLAGS}"
[$1]_CPPFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
[$1]_CXXFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
[$1]_LIBS+=" ${$1_OPTIONAL_LIBS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${qt_flags/manualflags/}" = "${qt_flags}"; then
CPPFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
CXXFLAGS+=" ${$1_OPTIONAL_CFLAGS}"
LIBS+=" ${$1_OPTIONAL_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
PKG_REQUIREMENTS+=" ${qt_modules_optional}"
], [
AC_MSG_NOTICE([Not found: ${qt_modules_optional}])
@ -133,7 +185,7 @@ AC_DEFUN([AX_CHECK_QT], [
])
AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1)
AX_CHECK_VALID_CXX_FLAG([-fPIC -fPIE], [position independent code flag])
if test "${MINGW}" != "no"; then
if test -n "${MINGW}"; then
AX_CHECK_VALID_CXX_FLAG([-Wl,-subsystem,windows], [windows console flag])
fi
AC_SUBST(QTDIR)
@ -169,42 +221,8 @@ qrc_%.cxx: %.qrc
'])
# SYNOPSIS
#
# AX_CHECK_QT([qt_prefix], [list-of-qt-modules], [optional-modules])
#
# DESCRIPTIONS
#
# qt_prefix
#
# Each call to AX_CHECK_QT should have a different prefix
# value (with a few exceptions discussed later on). This value,
# usually provided in uppercase, is used as prefix to the
# variables holding the compiler flags and libraries reported by
# pkg-config.
#
# For instance, if your prefix was to be FOO you'll be provided
# two variables FOO_CFLAGS and FOO_LIBS.
#
# This will also be used as message during the configure checks:
# checking for FOO....
#
# list-of-modules
#
# A single call to the macro can check for the presence of one or
# more qt modules; you'll see later how to make good use of this
# feature. Each entry in the list can have a version comparison
# specifier, with the same syntax as the Requires keyword in the
# data files themselves.
#
# optional-modules
#
# Optional list of more, optional modules, e.g. modules that
# exist only in Qt5, but not in Qt4, such as QtWidgets or
# QtWebKitWidgets
AC_DEFUN([AX_REQUIRE_QT], [
AX_CHECK_QT([$1], [$2], [$3])
AX_CHECK_QT([$1], [$2], [$3], [$4])
if ! test "$HAVE_$1" -eq 1; then
AC_MSG_ERROR([Required Qt modules not found: $2])
fi
@ -213,7 +231,6 @@ AC_DEFUN([AX_REQUIRE_QT], [
# Omit Qt Keywords
# AX_QT_NO_KEYWORDS
AC_DEFUN([AX_QT_NO_KEYWORDS], [
CPPFLAGS+=" -DQT_NO_KEYWORDS"
])

@ -8,7 +8,16 @@ m4_define([mrw_esyscmd_s], [m4_normalize(m4_esyscmd([$1]))])
# define least version number from subversion's revision number:
# it is taken modulo 256 due to a bug on Apple's MacOSX
m4_define(x_least, mrw_esyscmd_s([
m4_define(x_least, m4_ifdef([x_least_diff], mrw_esyscmd_s([
SVN_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-svn-checkout"
for path in . .. ../..; do
if svn info $path 2>&1 > /dev/null; then
SVN_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
break;
fi
done
echo $ECHO_N $(($SVN_REVISION))
]), mrw_esyscmd_s([
SVN_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-svn-checkout"
for path in . .. ../..; do
if svn info $path 2>&1 > /dev/null; then
@ -18,7 +27,7 @@ m4_define(x_least, mrw_esyscmd_s([
done
# Mac does not support LEAST > 255
echo $ECHO_N $(($SVN_REVISION%256))
]))
])))
# define version number from subversion's revision number:
# it is taken modulo 256 due to a bug on Apple's MacOSX
# add to x_minor if revision number is > 256
@ -34,7 +43,7 @@ m4_define(x_minor_diff, mrw_esyscmd_s([
echo $ECHO_N $(($SVN_REVISION/256))
]))
# setup version number
m4_define(x_version, [x_major.m4_eval(x_minor+x_minor_diff).x_least])
m4_define(x_version, [x_major.m4_ifdef([x_least_diff], x_minor, m4_eval(x_minor+x_minor_diff)).m4_eval(m4_ifdef([x_least_diff], [x_least-x_least_diff], [x_least]))])
## bugreport mail address is taken from <user@host> in first line of AUTHORS
m4_define(x_bugreport, mrw_esyscmd_s([
@ -107,14 +116,27 @@ AC_DEFUN([AX_SUBST], [
#
# configures the basic environment
AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
MINGW=no
MAC=no
case $host in
*mingw*) MINGW=yes;;
*darwin* | *rhapsody* | *macosx*) MAC=yes;;
esac
AM_CONDITIONAL(MINGW, test "$MINGW" = "yes")
AM_CONDITIONAL(MAC, test "$MAC" = "yes")
AC_MSG_CHECKING([target platfrom])
UNIX=1
MINGW=
MACOSX=
for h in ${target} ${target_os} ${host} ${host_os} \
${build} ${build_os} $(uname -s 2> /dev/null); do
p="$h is generic Unix"
case "$h" in
(*mingw*)
UNIX=; MINGW=1; p="MinGW"; break;;
(*Darwin*|*darwin*|*rhapsody*|*macosx*)
UNIX=; MACOSX=1; p="MacOSX"; break;;
esac
done
AC_MSG_RESULT($p)
AM_CONDITIONAL(UNIX, test "$UNIX" = "1")
AM_CONDITIONAL(MINGW, test "$MINGW" = "1")
AM_CONDITIONAL(MACOSX, test "$MACOSX" = "1")
AX_SUBST(UNIX)
AX_SUBST(MINGW)
AX_SUBST(MACOSX)
AM_CPPFLAGS+=" '-DMAKE_STRING(X)=\#X' '-DNAMESPACE=${PACKAGE_TARNAME//[^a-zA-Z0-9]/_}'"
AX_SUBST(NUMBERS)
AX_SUBST(HOME)
@ -127,8 +149,17 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
AUTHOR=$(head -1 AUTHORS)
AX_SUBST(AUTHOR)
_AM_SUBST_NOTMAKE([AUTHOR])
DISTRO=$(lsb_release -sc)
DISTRO=$(lsb_release -sc 2>/dev/null || uname -s 2>/dev/null)
AX_SUBST(DISTRO)
DISTRIBUTOR=$(lsb_release -si 2>/dev/null || uname -s 2>/dev/null)
case "${DISTRIBUTOR// /-}" in
(Ubuntu) UBUNTU=1; AX_SUBST(UBUNTU);;
(Debian) DEBIAN=1; AX_SUBST(DEBIAN);;
(SUSE-LINUX) SUSE=1; AX_SUBST(SUSE);;
(Fedora) FEDORA=1; AX_SUBST(FEDORA);;
(Centos) CENTOS=1; AX_SUBST(CENTOS);;
esac
AX_SUBST(DISTRIBUTOR)
BUILD_NUMBER=${BUILD_NUMBER:-1}
AX_SUBST(BUILD_NUMBER)
BUILD_DATE=$(LANG= date +"%a, %d %b %Y %H:%M:%S %z")
@ -156,11 +187,24 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
- all warnings result in an error
- doxygen warnings are treated as error too]); fi
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],
[compile for debugger])],
[have_debug="$enableval"], [have_debug="no"])
AM_CONDITIONAL(DEBUG, test "$enableval" = "yes")
if test "$have_debug" == "yes"; then
AC_MSG_NOTICE([Debug compile mode enabled]);
AM_CPPFLAGS="${AM_CPPFLAGS} -DDEBUG"
AM_CXXFLAGS="${AM_CXXFLAGS:-} -ggdb3 -O0"
AM_LDFLAGS="${AM_LDFLAGS} -ggdb3 -O0"
else
AM_CPPFLAGS="${AM_CPPFLAGS} -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG"
fi
AC_CONFIG_FILES([makefile])
AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-standard-project-targets], [makefile.in])
AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-standard-project-targets], [makefile.in])
AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-standard-project-targets], [makefile.in])
test -f makefile.in && sed -i '1iEXTRA_DIST = ' makefile.in
test -f makefile.in && cat >> makefile.in <<EOF
#### Begin: Appended by $0
EXTRA_DIST += bootstrap.sh ax_init_standard_project.m4 ax_cxx_compile_stdcxx_11.m4 \
@ -172,7 +216,7 @@ clean-standard-project-targets:
-rm \${PACKAGE_TARNAME}-\${PACKAGE_VERSION}.tar.gz
distclean-standard-project-targets:
-rm -r autom4te.cache
-rm aclocal.m4 config.guess config.sub configure depcomp compile install-sh ltmain.sh makefile missing mkinstalldirs
-rm aclocal.m4 config.guess config.sub configure depcomp compile install-sh ltmain.sh makefile missing mkinstalldirs test-driver
maintainer-clean-standard-project-targets:
-rm makefile.in
#### End: $0
@ -390,6 +434,8 @@ EOF
# $2 = module name (optional, if different from id)
# $3 = a header file to find (optional)
# $4 = alternative module names (space separated, optional)
# $5 = optional flags:
# manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
#
# uses PKG_CHECK_MODULES to test for a module
# then, if given, looks for the header file
@ -398,6 +444,7 @@ EOF
# fails if not found
AC_DEFUN([AX_PKG_REQUIRE], [
PKG_PROG_PKG_CONFIG
optional_flags="$5"
$1_found=no
secondpar="m4_default([$2], [$1])"
PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
@ -477,26 +524,47 @@ AC_DEFUN([AX_PKG_REQUIRE], [
AC_MSG_ERROR([Feature $1 not found please install module $secondpar])
fi
fi
CPPFLAGS+=" ${$1_CFLAGS}"
CXXFLAGS+=" ${$1_CFLAGS}"
LIBS+=" ${$1_LIBS}"
[$1]_CPPFLAGS="${$1_CFLAGS}"
[$1]_CXXFLAGS="${$1_CFLAGS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${optional_flags/manualflags/}" = "${optional_flags}"; then
CPPFLAGS+=" ${$1_CPPFLAGS}"
CXXFLAGS+=" ${$1_CXXFLAGS}"
LIBS+=" ${$1_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
])
# check if a specific package exists
# - parameter:
# $1 = unique id (no special characters)
# $2 = module name (optional, if different from id)
# $3 = optional flags:
# manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
#
# uses PKG_CHECK_MODULES to test for a module
# sets automake conditional HAVE_$1 to 0 (not found) or 1 (found)
# sets all flags, so that the module can be used everywhere
AC_DEFUN([AX_PKG_CHECK], [
optional_flags="$3"
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
HAVE_$1=1
CPPFLAGS+=" ${$1_CFLAGS}"
CXXFLAGS+=" ${$1_CFLAGS}"
LIBS+=" ${$1_LIBS}"
[$1]_CPPFLAGS="${$1_CFLAGS}"
[$1]_CXXFLAGS="${$1_CFLAGS}"
AC_SUBST([$1]_CPPFLAGS)
AC_SUBST([$1]_CXXFLAGS)
if test "${optional_flags/manualflags/}" = "${optional_flags}"; then
CPPFLAGS+=" ${$1_CPPFLAGS}"
CXXFLAGS+=" ${$1_CXXFLAGS}"
LIBS+=" ${$1_LIBS}"
AC_MSG_NOTICE([Adding flags for $1])
else
AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
fi
if test -z "$PKG_REQUIREMENTS"; then
PKG_REQUIREMENTS="m4_default([$2], [$1])"
else

@ -672,7 +672,7 @@ if testtag AX_USE_DOXYGEN; then
doxyreplace INLINE_SOURCES YES
doxyreplace GENERATE_TESTLIST YES
doxyreplace GENERATE_TREEVIEW NO
doxyreplace SEARCHENGINE YES
doxyreplace SEARCHENGINE NO
doxyreplace GENERATE_HTML YES
doxyreplace GENERATE_LATEX NO
doxyreplace LATEX_BATCHMODE YES

@ -8,7 +8,7 @@
m4_define(x_package_name, safechat) # project's name
m4_define(x_major, 0) # project's major version
m4_define(x_minor, 2) # project's minor version
m4_define(x_minor, 3) # project's minor version
m4_include(ax_init_standard_project.m4)
AC_INIT(x_package_name, x_version, x_package_name)
AM_INIT_AUTOMAKE([1.9 tar-pax])
@ -17,11 +17,11 @@ AX_INIT_STANDARD_PROJECT
# requirements, uncomment, what you need:
#AX_USE_CXX
#AX_USE_LIBTOOL
#AX_USE_SCRIPTS
AX_USE_SCRIPTS
AX_USE_DOXYGEN
AX_USE_DEBIAN_PACKAGING
AX_BUILD_HTML
#AX_USE_RPM_PACKAGING
AX_USE_RPM_PACKAGING
#AX_USE_CPPUNIT
#AX_BUILD_EXAMPLES

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="232" android:versionName="0.2.32" package="ch.safechat" xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:hardwareAccelerated="true" android:versionCode="333" android:versionName="0.3.33" package="ch.safechat" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="ch.safechat" version="0.2.32" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="ch.safechat" version="0.3.33" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="loglevel" value="DEBUG" />
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />

@ -34,4 +34,53 @@ function success($txt) {
exit;
}
function getoption($name, $default) {
if (!isset($OPTION[$name])) {
$q = $db->query("select value from options where name='$name';");
if ($q->num_rows==1) {
$OPTION[$name]=$q->fetch_row()[0];
} else {
if (isset($_SERVER[$name]))
$OPTION[$name]=$_SERVER[$name];
else
$OPTION[$name]=$default;
$q = $db->query("insert into options (name, value) values ('$name', '$value');");
}
}
return $OPTION[$name];
}
/// Create user safechat as server's identity
/** Server has reserved username @c safechat */
function createSafechatUser() {
$q = $db->query("select pubkey from user where name='safechat';");
if ($q->num_rows!=1 && $user=="safechat") {
$KEY_LENGTH=getoption("KEYLEN", "4096");
$SAFECHAT_NAME=getoption("NAME", "Safe Chat");
$SAFECHAT_COMMENT=getoption("COMMENT", "https://safechat.ch");
$SAFECHAT_EMAIL=getoption("EMAIL", "server@safechat.ch");
$PASSWORD=getoption("PASSWORD", "s3Cr37");
$create_key_cmd=<<<EOT
gpg -v -v --gen-key --batch <<EOF
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: ${SAFECHAT_NAME}
Name-Comment: ${SAFECHAT_COMMENT}
Name-Email: ${SAFECHAT_EMAIL}
Expire-Date: 0
Passphrase: ${PASSWORD}
%echo generating key for ${SAFECHAT_NAME} ...
%commit
%echo done.
EOF
EOT;
system($create_key_cmd);
gnupg_setarmor($pgp, 1);
$export = gnupg_export($pgp, ${SAFECHAT_NAME});
$q = $db->query("insert into user (name, pubkey) values ('safechat', '$export');");
}
}
?>

@ -28,8 +28,7 @@ try {
require_once("usertable.php");
$user = $db->real_escape_string($_REQUEST['user']);
$pubkey = $db->real_escape_string($_REQUEST['pubkey']);
$pgp = gnupg_init();
if (!$pgp) error("pgp on server failed");
if ($user=="safechat") error("username safechat is reserved for server");
$verify = gnupg_import($pgp, $_REQUEST['pubkey']);
if (!$verify) error("wrong identity");
$q = $db->query("select * from user where name='$user' and pubkey='$pubkey';");

@ -21,16 +21,12 @@
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
require_once("functions.php");
mysqli_report(MYSQLI_REPORT_STRICT);
require_once("opendb.php");
try {
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);
$db->query("create database if not exists safechat;");
$db->select_db("safechat");
$db->query('create table if not exists message (id int primary key not null auto_increment, time timestamp default current_timestamp, user varchar(50) not null, msg longtext not null);');
$db->query('set global max_allowed_packet=1000000000');
$db->query('set global net_buffer_length=1000000');
} catch (Exception $e) {
echo json_encode(null);
error('database error on server');
}
?>

@ -29,6 +29,11 @@ try {
require_once("usertable.php");
$user = $db->real_escape_string($_REQUEST['user']);
$q = $db->query("select pubkey from user where name='$user';");
if ($q->num_rows!=1 && $user=="safechat") {
require_once("optionstable.php");
createSafechatUser();
$q = $db->query("select pubkey from user where name='$user';");
}
if ($q->num_rows==1) {
echo json_encode($q->fetch_row()[0]);
} else {

@ -286,7 +286,7 @@ function checkpartner(user) {
function createkeypair(user, pwd) {
status("generate keys");
openpgp.generateKeyPair({
numBits: 1024,
numBits: 4096,
userId: user,
passphrase: pwd
}).then(function(keyPair) {
@ -403,6 +403,37 @@ function setreceiver(name) {
$("#msg").focus();
}
var userMap = null;
/// Get a user's public key.
/** The first time, gets it from the server, later from the cache. */
function getPublicKey(user) {
var deferredObject = $.Deferred();
if (userMap == null) {
if (localStorage.userMap) {
userMap = JSON.parse(localStorage.userMap);
console.log("got userMap from localStorage");
} else {
userMap = new Array();
}
}
if (userMap[user]) {
console.log("user "+user+" is in cache");
deferredObject.resolve(userMap[user]);
} else {
$.post("pubkey.php", {user: user}) // get sender's key
.done(function(pk) {
console.log("got user "+user+" from server");
userMap[user] = pk;
localStorage.userMap = JSON.stringify(userMap);
deferredObject.resolve(pk);
}).fail(function(e) {
error("offline");
deferredObject.reject(e);
});
}
return deferredObject.promise();
}
var startmsg = 0; ///< number of last downloaded message
/// Poll For New Messages, Get And Show Them
/** The global variable @ref startmsg stores the id of the last
@ -421,7 +452,7 @@ function get() {
if (msgs) {
msgs.forEach(function(e) { // one single message
if (startmsg<Number(e.id)) startmsg = Number(e.id);
$.post("pubkey.php", {user: e.user}) // get sender's key
getPublicKey(e.user) // get sender's key
.done(function(pk) {
var res=JSON.parse(pk);
var key=openpgp.key.readArmored(res);
@ -481,7 +512,7 @@ function get() {
function sendmessage(recv, txt) {
notice("1/3 preparing message ...");
$("#message").fadeOut("slow");
$.post("pubkey.php", {user: recv}) // get receiver's public key
getPublicKey(recv) // get receiver's public key
.done(function(pk) {
var res=JSON.parse(pk);
var key=openpgp.key.readArmored(res);

@ -29,9 +29,7 @@ try {
require_once("usertable.php");
$user = $db->real_escape_string($_REQUEST['user']);
$msg = $db->real_escape_string($_REQUEST['msg']);
$pgp = gnupg_init();
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]);

@ -22,14 +22,10 @@
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
require_once("functions.php");
mysqli_report(MYSQLI_REPORT_STRICT);
require_once("opendb.php");
try {
$db = new mysqli("mysql", "root", $_SERVER["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]);
$db->query("create database if not exists safechat;");
$db->select_db("safechat");
$db->query('create table if not exists user (name varchar(50) not null unique key, pubkey text not null);');
} catch (Exception $e) {
echo json_encode(null);
error('database error on server');
}
?>

@ -1,11 +1,13 @@
## @id $Id$
#
# This file has been added by bootstrap.sh on Wed, 15 July 2015 10:02:57 +0200
# This file has been added by bootstrap.sh on Sun, 11 October 2015 13:20:54 +0200
# Feel free to change it or even remove and rebuild it, up to your needs
#
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
SUBDIRS = doc html cordova
SUBDIRS = scripts doc html
doc_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
MAINTAINERCLEANFILES = makefile.in

@ -13,17 +13,17 @@
SCHROOTNAME="$1"
PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac)
sed 's,@[^@]*@,dummytext,g' ${PACKAGE_NAME}.spec.in > ${PACKAGE_NAME}.spec
if test -n "${SCHROOTNAME}"; then
FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
schroot -c ${SCHROOTNAME} -- ./bootstrap.sh -t dist
FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
if test -n "${FILES}"; then
schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \
schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \
schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES}
fi
else
FILES=$(LANG= rpmbuild -bb --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
./bootstrap.sh -t dist
FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
if test -n "${FILES}"; then
yum install -y ${FILES} || \
zypper install -y ${FILES} || \

@ -0,0 +1,60 @@
Summary: @DESCRIPTION@
Name: @PACKAGE_NAME@
Version: @VERSION@
Release: @BUILD_NUMBER@%{?dist}
License: LGPL
Group: Applications/...
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gnupg, subversion, automake, autoconf, doxygen
%if 0%{?fedora} != 20
BuildRequires: graphviz
%endif
%if 0%{?fedora} || 0%{?rhel} || 0%{?rhl} || 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version}
BuildRequires: pkgconfig, redhat-lsb
%if ! ( 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} )
BuildRequires: mscgen
%else
%endif
%else%if 0%{?suse_version} || 0%{?sles_version}
BuildRequires: pkg-config, lsb-release
%if 0%{?suse_version} < 1200 || 0%{?sles_version} < 1200
%else
%endif
%endif%endif
%description
@README@
%prep
%setup -q
./configure --prefix=/usr \
--sysconfdir=/etc \
--docdir=/usr/share/doc/packages/@PACKAGE_NAME@ \
--libdir=/usr/%_lib
%build
make
%install
DESTDIR=$RPM_BUILD_ROOT make install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/usr/bin/*
%doc
/usr/share/*
%changelog

@ -0,0 +1,11 @@
## @id $Id$
#
# This file has been added by bootstrap.sh on Sun, 11 October 2015 12:15:12 +0200
# Feel free to change it or even remove and rebuild it, up to your needs
#
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
dist_sbin_SCRIPTS = safechat-install.sh
MAINTAINERCLEANFILES = makefile.in
Loading…
Cancel
Save