Commit 7749d100 authored by thiaramus's avatar thiaramus
Browse files

Removed frontend related files unnecessary for API

parent 7cc976e1
{
"directory": "src/bower_components"
}
/*
* Copyleft 2017 by Philipp Giebel (stimpy@kuehlbox.wtf)
* Released under GPLv3: http://www.gnu.org/copyleft/gpl.html
*
*/
module.exports = function (grunt) {
// Project configuration.
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
main: {
files: {
'src/assets/css/complete.min.css': [ 'src/bower_components/bootstrap/dist/css/bootstrap.min.css', 'src/assets/css/index.css' ]
}
}
},
uglify: {
main: {
files: {
'src/assets/js/complete.min.js': ['src/bower_components/jquery/dist/jquery.min.js', 'src/bower_components/bootstrap/dist/js/bootstrap.min.js', 'src/bower_components/crypto-js/crypto-js.js', 'src/assets/js/index.js' ],
'src/assets/js/iecompat.min.js': ['src/bower_components/html5shiv/dist/html5shiv.min.js', 'src/bower_components/respond/dest/respond.min.js' ]
}
}
},
copy: {
main: {
files: [
// includes files within path and its sub-directories
{expand: true, cwd: 'src/assets/classes', src: ['**'], dest: 'dist/assets/classes/'},
{expand: true, cwd: 'src/assets/js', src: ['complete.min.js'], dest: 'dist/assets/js/'},
{expand: true, cwd: 'src/assets/favicons', src: ['**'], dest: 'dist/'},
{expand: true, cwd: 'src/assets/css', src: ['complete.min.css'], dest: 'dist/assets/css/'},
{expand: true, cwd: 'src/assets/js', src: ['iecompat.min.js'], dest: 'dist/assets/js/'},
{expand: true, cwd: 'src/assets/fonts', src: ['**'], dest: 'dist/assets/fonts/'},
{expand: true, cwd: 'src/bower_components/bootstrap/dist/fonts', src: ['**'], dest: 'dist/assets/fonts/'},
{src: 'src/bower_components/ie10-viewport-bug-workaround/dist/ie10-viewport-bug-workaround.min.js', dest: 'dist/assets/js/ie10-viewport-bug-workaround.min.js'},
{src: 'src/ajax.php', dest: 'dist/ajax.php'},
{src: 'src/bin/husky2ini.php', dest: 'dist/bin/husky2ini.php'},
{src: 'src/assets/include/areas.ini.dist', dest: 'dist/assets/include/areas.ini.dist'},
{src: 'src/assets/include/config.inc.php.dist', dest: 'dist/assets/include/config.inc.php.dist'},
{src: 'src/assets/include/compat.inc.php', dest: 'dist/assets/include/compat.inc.php'}
]
},
process: {
options: { process: function (content, srcpath ) { return content.replace(/'%VERSION%'/g, "'0.1.4'"); } },
files: [
{src: 'src/assets/include/init.inc.php', dest: 'dist/assets/include/init.inc.php'}
]
}
},
processhtml: {
dist: {
options: {
process: true,
data: {
title: 'webJAM',
message: 'JAM Message Reader'
}
},
files: {
'dist/index.php': ['src/index.php'],
'dist/bin/pwgen.php': ['src/bin/pwgen.php']
}
}
},
clean: ["dist/*", "src/js/complete.min.js", "src/css/complete.min.css", "src/css/iecompat.min.css" ]
});
grunt.registerTask('build', ["cssmin", "uglify"]);
grunt.registerTask('dist', ["copy", "processhtml"]);
grunt.registerTask('default', ["build", "dist"]);
};
{
"name": "website_jamreader",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"bootstrap": "3.3.7",
"html5shiv": "3.7.3",
"respond": "1.4.2",
"crypto-js": "3.1.9",
"ie10-viewport-bug-workaround": "1.0.3"
},
"devDependencies": {}
}
<?php
/*
* webJAM - A modern JAM MessageBase Editor
* Copyright (C) 2017 Philipp Giebel (stimpy@kuehlbox.wtf)
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see (http://www.gnu.org/licenses/).
*
* * filename: ajax.php
* * description: server-side file for processind ajax calls done by the webJAM Webinterface.
*
*/
require_once 'assets/include/init.inc.php';
if ( $user == false ) die('forbidden');
$function = filter_input( INPUT_POST, 'function', FILTER_SANITIZE_STRING );
switch ( $function ) {
case 'getheaders':
$start = intval( filter_input( INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT ) );
$lastnum = $jam->getLastNumActive( $echos[$echo]['filename'] );
if ( $lastnum-$start-30 >= 0 ) {
$headers = $jam->getMsgHeader( $echos[$echo]['filename'], $lastnum-$start-30, 30 );
} elseif ( $start < $lastnum ) {
$headers = $jam->getMsgHeader( $echos[$echo]['filename'], 0, $lastnum-$start );
} else {
$headers = array();
}
foreach ( $headers as &$r ) {
if ( array_search( 'MSG_DELETED', $r['attribute1'] ) ) {
$r = false;
} else {
if ( ( array_search( 'MSG_PRIVATE', $r['attribute1'] ) !== false ) OR ( $echos[$echo]['group'] == 'netmail' ) ) {
if ( ( !array_search( $r['OADDRESS'][0], $user['groups'] ) )
AND ( !array_search( $r['DADDRESS'][0], $user['groups'] ) )
AND ( strtolower( $r['RECEIVERNAME'][0] ) != strtolower( $user['realname'] ) )
AND ( strtolower( $r['SENDERNAME'][0] ) != strtolower( $user['realname'] ) )
AND ( !array_search( strtolower( $r['RECEIVERNAME'][0] ), $user['aliases'] ) )
AND ( !array_search( strtolower( $r['SENDERNAME'][0] ), $user['aliases'] ) ) ) {
$r = false;
}
}
}
}
echo json_encode( $headers );
break;
case 'getmessage':
if ( $amb->isAllowedGroup( $user['username'], $echo ) ) {
$lastnum = $jam->getLastNumActive( $echos[$echo]['filename'] );
$message = $jam->getMessage( $echos[$echo]['filename'], $lastnum-$msgid );
$message['text'] = str_replace( '<', '&lt;', $message['text'] );
$message['text'] = str_replace( '>', '&gt;', $message['text'] );
$message['text'] = $amb->colorize( $amb->linkify( $message['text'] ) );
echo json_encode( $message );
}
break;
case 'findname':
$search = filter_input( INPUT_POST, 'search', FILTER_SANITIZE_STRING );
$ret = array();
foreach ( $cfg['nodelists'] as $n ) {
$nodelist->readFile( $nodelist->getLatest( $n ) );
$add = $nodelist->findName( $search );
if ( is_array( $add ) ) $ret = array_merge( $ret, $add );
}
echo json_encode( $ret );
break;
case 'savemessage':
if ( $user['readonly'] === false ) {
$receivername = filter_input( INPUT_POST, 'receivername', FILTER_SANITIZE_STRING );
$receiveraka = filter_input( INPUT_POST, 'receiveraka', FILTER_SANITIZE_STRING );
$subject = filter_input( INPUT_POST, 'subject', FILTER_SANITIZE_STRING );
$message = filter_input( INPUT_POST, 'message', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
$echo = filter_input( INPUT_POST, 'echo', FILTER_SANITIZE_STRING );
$replyid = filter_input( INPUT_POST, 'replyid', FILTER_SANITIZE_NUMBER_INT );
$fromaka = false;
$defaultaka = false;
$domain = false;
$netmail = false;
if ( ( $echo == 'netmail' ) AND ( !array_key_exists( 'netmail', $echos ) ) ) {
$netmail = true;
if ( $receiveraka ) {
foreach ( $user['groups'] as $k => $g ) {
if ( ( explode( ':', $g )[0] == explode( ':', $receiveraka )[0] ) AND ( $echo == 'netmail' ) ) {
$fromaka = $g;
$domain = $echo = $k;
}
}
}
}
if ( $replyid != NULL ) {
$header = $jam->getMsgHeader( $echos[$echo]['filename'], $jam->getLastNumActive( $echos[$echo]['filename'] )-1-$replyid, 1 );
$replyid = $header[0]['MSGID'][0];
}
foreach ( $user['groups'] as $k => $g ) {
if ( $defaultaka == false ) $defaultaka = $g;
if ( !$fromaka ) {
if ( $receiveraka ) {
if ( ( explode( ':', $g )[0] == explode( ':', $receiveraka )[0] ) AND ( $fromaka == false ) ) {
$fromaka = $g;
$domain = $k;
}
} elseif ( $k == $echos[$echo]['group'] ) {
$fromaka = $g;
$domain = $k;
}
}
}
if ( $fromaka == false ) $fromaka = $defaultaka;
$message .= '\n\n--- webJAM v'. VERSION .'\n * Origin: '. substr( $user['origin'], 0, 65-strlen( $fromaka) ) .' ('. $fromaka .')\n';
if ( $netmail == true ) {
echo $jam->saveMessage( $echos[$echo]['filename'], $user['realname'], $fromaka, $receivername, $receiveraka, $subject, time(), time(), time(), $message, $domain, $replyid, array( 'MSG_LOCAL', 'MSG_PRIVATE', 'MSG_TYPENET' ) );
if ( $cfg['semaphores']['netscan'] != false ) $res = touch( $cfg['semaphores']['netscan'] );
} elseif ( $echo == 'netmail' ) {
$ret = $jam->saveMessage( $echos[$echo]['filename'], $user['realname'], $fromaka, $receivername, $receiveraka, $subject, time(), time(), time(), $message, $domain, $replyid, array( 'MSG_LOCAL', 'MSG_PRIVATE', 'MSG_TYPENET' ) );
if ( $ret ) echo 'netmail';
if ( $cfg['semaphores']['netscan'] != false ) $res = touch( $cfg['semaphores']['netscan'] );
} else {
echo $jam->saveMessage( $echos[$echo]['filename'], $user['realname'], $fromaka, $receivername, false, $subject, time(), time(), time(), $message, $domain, $replyid );
if ( $cfg['semaphores']['echoscan'] != false ) $res = touch( $cfg['semaphores']['echoscan'] );
}
} else {
echo -1;
}
break;
}
<?php
/*
* webJAM - A modern JAM MessageBase Editor
* Copyright (C) 2017 Philipp Giebel (stimpy@kuehlbox.wtf)
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see (http://www.gnu.org/licenses/).
*
* + filename: helper.class.php
* + description: Internal helper class for use with webJAM.
*
*/
class amb {
function __construct( ) {
}
function __destruct() {
}
function isAllowedGroup( $username, $echo ) {
global $cfg, $echos;
foreach ( array_keys( $cfg['users'][$username]['groups'] ) as $g ) {
if ( $echos[$echo]['group'] == $g ) return true;
}
return false;
}
function colorize( $input ) {
$input = preg_replace( "/([\r\n]\s*---\s[^\r\n]*)/", '<span class="dim">$1</span>', $input );
$input = preg_replace( "/([\r\n]\s*\* Origin:[^\r\n]*)/", '<span class="origin">$1</span>', $input );
$input = preg_replace( "/([\r\n]\s*\w{0,2}>)([^\r\n]*)/", '<span class="quote"><span class="op">$1</span>$2</span>', $input );
$input = preg_replace_callback( "/".chr(27)."\[(\d+)C/", function($n) { $ret = ''; for ( $i = 0; $i < $n[1]; $i++ ) { $ret .= ' '; } return $ret; }, $input );
$input = preg_replace( "/".chr(27)."\[([\d;\?]*)[mhDHJBAusC]/", "", $input );
return $input;
}
function linkify( $input ) {
$input = preg_replace( '/(https?:\/\/[\da-zA-Z\.-]+\.[a-zA-Z\.]{2,6}[^\s@>]*)\s/', '<a href="$1" target="_blank">$0</a>', $input );
$input = preg_replace( '/([a-zA-Z0-9_\.-]+@[\da-zA-Z\.-]+\.[a-zA-Z\.]{2,6})/', '<a href="mailto:$1">$0</a>', $input );
return $input;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment