Initial commit

This commit is contained in:
mmk2410 2016-04-06 17:30:05 +02:00
commit 78a4e70036
24 changed files with 1067 additions and 0 deletions

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
*.css
main.js
node_modules/
.hhconfig
assets/
templates/
lists/
vendor/

22
LICENSE.txt Normal file
View file

@ -0,0 +1,22 @@
COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

34
README.md Normal file
View file

@ -0,0 +1,34 @@
# Filespread
Filespread is a simple webapp to make file spreading over mail easy by providing the ability to manage different templates and different address lists.
## Installation
Fork the git repo and run
```
npm install
```
```
composer install
```
Make sure you have gulp installed on your system and run
```
gulp sass
gulp coffee
```
Now make sure that the server can write in the folders `templates, assets and lists`.
Finally remove the example files.
# License
Filespread is licensed under the MIT license.
# Contributing
Please refer to the [Contributing Guidlines](https://mmk2410.org/contribute/)

14
composer.json Executable file
View file

@ -0,0 +1,14 @@
{
"name": "mmk2410/filespread",
"description": "A simple program for sending a mail with attachments",
"require": {
"phpmailer/phpmailer": "^5.2"
},
"license": "MIT",
"authors": [
{
"name": "mmk2410",
"email": "marcelmichaelkapfer@yahoo.co.nz"
}
]
}

78
composer.lock generated Executable file
View file

@ -0,0 +1,78 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "ae00a14ff5f433c662a467156198e047",
"packages": [
{
"name": "phpmailer/phpmailer",
"version": "v5.2.13",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "45df3a88f7f46071e10d0b600f228d19f95911b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/45df3a88f7f46071e10d0b600f228d19f95911b3",
"reference": "45df3a88f7f46071e10d0b600f228d19f95911b3",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "*",
"phpunit/phpunit": "4.7.*"
},
"suggest": {
"league/oauth2-client": "Needed for Gmail's XOAUTH2 authentication system"
},
"type": "library",
"autoload": {
"classmap": [
"class.phpmailer.php",
"class.phpmaileroauth.php",
"class.phpmaileroauthgoogle.php",
"class.smtp.php",
"class.pop3.php",
"extras/EasyPeasyICS.php",
"extras/ntlm_sasl_client.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
},
{
"name": "Brent R. Matzelle"
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2015-09-14 09:18:12"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

12
filespread.ini Normal file
View file

@ -0,0 +1,12 @@
; This is the config file for filespread
; Modify the values to your needs before running filespread
[filespread]
; Set your timezone (https://secure.php.net/manual/en/timezones.php)
timezone = "UTC"
[user]
; email address which is given as a sender address
email = "example@example.com"
; name which is given as a sender name
name = "John"

20
gulpfile.coffee Executable file
View file

@ -0,0 +1,20 @@
# COPYRIGHT 2016 (c) Marcel Kapfer (mmk2410)
# MIT License
gulp = require 'gulp'
coffee = require 'gulp-coffee'
sass = require 'gulp-sass'
gulp.task 'coffee', ->
gulp.src './res/js/*.coffee'
.pipe coffee()
.pipe gulp.dest './res/js/'
gulp.task 'sass', ->
gulp.src './res/css/*.sass'
.pipe sass()
.pipe gulp.dest './res/css/'
gulp.task 'default', ->
gulp.watch './res/js/*.coffee', ['coffee']
gulp.watch './res/css/*.sass', ['sass']

175
index.html Executable file
View file

@ -0,0 +1,175 @@
<!DOCTYPE html>
<!--
FileSpread
A simple file-spread-over-mail web app
MIT License
2015 - 2016 (c) Marcel Kapfer (mmk2410) <marcelmichaelkapfer@yahoo.co.nz>
-->
<html>
<head>
<meta charset="utf-8" />
<title>FileSpread</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="A web file spreader over mail" />
<meta name="theme-color" content="#9c27b0" />
<link rel="manifest" href="manifest.json" />
<meta name="msapplication-TileColor" content="#9c27b0"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="application-name" content="FileSpread"/>
<!--
<meta rel="icon" sizes="192x192" href="images/touch/chrome-touch-icon-192x192.png"/>
-->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="FileSpread"/>
<!--
<link rel="apple-touch-icon" href="images/touch/apple-touch-icon.png" />
-->
<!--
<meta name="msapplication-TileImage" content="images/touch/ms-touch-icon0144x144.png" />
-->
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:400,600,300,700" />
<link rel="stylesheet" type="text/css" href="./res/css/main.css" />
</head>
<body>
<div class="header">
<span class="title">FileSpread</span>
</div>
<section class="card">
<div class="headline">File Upload</div>
<p>
Choose a file to spread
</p>
<form action="res/php/upload.php" enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
<input name="userfile" type="file" value="Choose a file" />
<br />
<br />
<input type="submit" class="button" style="padding: 0px;" value="UPLOAD" />
</form>
</section>
<section class="card">
<div class="headline">Email content</div>
<p>
Select a template:
</p>
<select id="templates_list"></select>
<p>Change the text of the email if you want.</p>
<p>Title:</p><input id="mailtitle" name="title" class="itextfield" />
<p>Text:</p><textarea id="mailtext" name="text" class="itextarea"></textarea>
<p>Filename:</p><input id="filename" name="filename" class="itextfield" />
</section>
<section class="card">
<div class="headline">Email Addresses</div>
<p>
Select a address list:
</p>
<select id="address_list"></select>
<p>These are the email addresses, the mail is going to be send.</p>
<div id="addresses"></div>
</section>
<section class="card">
<div class="headline">Send Mail</div>
<p>
Send now the the mail with the file attachment to the listed addresses.
</p>
<span class="button" id="send">SEND</span>
</section>
<section class="card">
<div class="headline">Change Template</div>
<p>
Select a template you want to change:
</p>
<select id="edit_templates_list">
<option value="none">None Selected</option>
</select>
<p class="edit_template">Change the text of the template.</p>
<p class="edit_template">Title:</p><input id="edit_mailtitle" name="title" class="itextfield edit_template" />
<p class="edit_template">Text:</p><textarea id="edit_mailtext" name="text" class="itextarea edit_template"></textarea>
<p class="edit_template">Filename:</p><input id="edit_filename" name="filename" class="itextfield edit_template" />
<p class="edit_template">
<span class="button" id="save_template">SAVE</span>
</p>
</section>
<section class="card">
<div class="headline">Create Template</div>
<p>
Template name (filename.txt):
</p>
<input id="create_template_name" name="filename" class="itextfield" />
<p>
<span class="button" id="create_template">CREATE</span>
</p>
</section>
<section class="card">
<div class="headline">Delete Template</div>
<p>
Select the template you want to remove:
</p>
<select id="remove-template-list">
<option value="none">None Selected</option>
</select>
<p class="remove_template">
<span class="button" id="remove-template">REMOVE</span>
</p>
</section>
<section class="card">
<div class="headline">Change List</div>
<p>
Select the address list you want to change:
</p>
<select id="edit-address-list">
<option value="none">None Selected</option>
</select>
<p class="edit_address">Change the content of the list:</p>
<textarea id="edit-addresses" class="itextarea edit_address"></textarea>
<p class="edit_address">
<span class="button" id="save-addresses">SAVE</span>
</p>
</section>
<section class="card">
<div class="headline">Create List</div>
<p>
List name (filename.txt):
</p>
<input id="create-list-name" name="filename" class="itextfield" />
<p>
<span class="button" id="create-list">CREATE</span>
</p>
</section>
<section class="card">
<div class="headline">Delete List</div>
<p>
Select the list you want to remove:
</p>
<select id="remove-list-list">
<option value="none">None Selected</option>
</select>
<p class="remove_list">
<span class="button" id="remove-list">REMOVE</span>
</p>
</section>
<script src="./res/js/jquery-2.1.4.min.js"></script>
<script src="./res/js/main.js"></script>
</body>
</html>

19
manifest.json Executable file
View file

@ -0,0 +1,19 @@
{
"name": "FileSpread",
"short_name": "FileSpread",
"icons" : [{
"src": "images/touch/icon-128x128.png",
"sizes": "128x128"
}, {
"src": "images/touch/apple-touch-icon.png",
"sizes": "152x152"
}, {
"src": "images/touch/ms-touch-icon-144x144-precomposed.png",
"sizes": "144x144"
}, {
"src": "images/touch/chrome-touch-icon-192x192.png",
"sizes": "192x192"
}],
"start_url": "./",
"display": "standalone"
}

22
package.json Normal file
View file

@ -0,0 +1,22 @@
{
"name": "filespread",
"version": "0.1.0",
"description": "file spreader over mail",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Marcel Kaper (mmk2410)",
"license": "MIT",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-coffee": "^2.3.1",
"gulp-sass": "^2.1.0",
"node-sass": "^3.4.2"
},
"repository" :
{
"type" : "git",
"url" : "https://git.mmk2410.org/filespread"
}
}

201
res/css/main.sass Executable file
View file

@ -0,0 +1,201 @@
// Variables
// COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
// MIT License
$primaryColor: #9c27b0
/* BODY */
body
font-family: "Roboto", sans-serif
background: #f6f6f6
color: #383838
margin-top: 94px
.main
height: 100%
width: 100%
margin-left: 0px
/* HEADER */
.header
background-color: $primaryColor
position: fixed
top: 0px
right: 0px
left: 0px
width: 100%
height: 64px
box-shadow: 2px 0px 2px 2px rgba(62, 62, 62, 0.45)
.title
color: #fff
font-size: 23px
text-decoration: none
line-height: 64px
vertical-align: middle
left: 75px
position: absolute
/* MAIN */
.card
margin-right: auto
margin-left: auto
width: 75%
background: #fff
border-radius: 2px
padding: 24px
box-shadow: 0px 1px 1.5px 1.5px rgba(62, 62, 62, 0.3)
margin-bottom: 40px
max-width: 1160px
.headline
font-size: 24px
color: #383838!important
text-decoration: none
display: block
padding-bottom: 8px
border-bottom: none!important
.card > p
font-size: 14px
line-height: 24px
.table-content
max-height: 200px
overflow: auto
/* FOOTER */
.footer
font-size: 12px
text-align: center
.footer a
color: #383838
text-decoration: none
border-bottom: 1px solid transparent
border-bottom-color: transparent
transition: border-bottom-color 150ms ease-in-out 100ms
.footer a:hover
border-bottom-color: #383838
/* BUTTON */
.button
text-decoration: none
color: #fff
background-color: $primaryColor
line-height: 36px
min-width: 64px
text-align: center
height: 36px
padding: 8px
border-width: 1px
border-style: solid
border-color: $primaryColor
box-shadow: 0.4px 1px 1.5px 1px #aaa
-moz-box-shadow: 0.4px 1px 1.5px 1px #aaa
-webkit-box-shadow: 0.4px 1px 1.5px 1px #aaa
border-radius: 2px
margin-top: 4px
margin-bottom: 5px
letter-spacing: 0.4px
font-weight: 700
font-size: 14px
transition-property: box-shadow
transition-delay: 50ms
transition-duration: 125ms
transition-timing-function: ease
-moz-transition-property: box-shadow
-moz-transition-delay: 50ms
-moz-transition-duration: 125ms
-moz-transition-timing-function: ease
-webkit-transition-property: box-shadow
-webkit-transition-delay: 50ms
-webkit-transition-duration: 125ms
-webkit-transition-timing-function: ease
cursor: pointer
.button:hover, .button:hover
box-shadow: 0.5px 1.8px 2.1px 1.4px #aaa
-moz-box-shadow: 0.5px 1.8px 2.1px 1.4px #aaa
-webkit-box-shadow: 0.5px 1.8px 2.1px 1.4px #aaa
input.button
padding: 0px 8px
/* INPUT FIELD */
.itextfield
border-color: transparent
border-width: 1px
font-size: 16px
line-height: 22px
width: 50%
border-bottom-color: #aaa
transition-property: border-bottom-color
transition-delay: 50ms
transition-duration: 125ms
transition-timing-function: ease
-moz-transition-property: border-bottom-color
-moz-transition-delay: 50ms
-moz-transition-duration: 125ms
-moz-transition-timing-function: ease
-webkit-transition-property: border-bottom-color
-webkit-transition-delay: 50ms
-webkit-transition-duration: 125ms
-webkit-transition-timing-function: ease
.itextfield:focus
border-bottom-color: #E91E63
border-width: 2px
outline: none
.itextarea
@extend .itextfield
min-height: 150px
.itextarea:focus
@extend .itextfield
/* FILESPREAD */
.edit_template
display: none
.edit_list
display: none
.remove_template
display: none
.edit_address
display: none
.remove_list
display: none
/* FORM */
form
margin-top: 20px
@media screen and (min-width: 1440px)
.card
width: 1160px
@media screen and (max-width: 720px)
.card
width: 82%
.title
left: 25px
.itextfield
width: 100%

4
res/js/jquery-2.1.4.min.js vendored Executable file

File diff suppressed because one or more lines are too long

251
res/js/main.coffee Executable file
View file

@ -0,0 +1,251 @@
# CoffeeScript for filespread
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
main = ->
$("#send").click ->
url = "./res/php/sendmail.php?list=" + $("#address_list").val() +
"&template=" + $("#templates_list").val()
$.get url, (data) ->
if data is "0"
alert "Mail sent!"
else
alert "Sending mail failed!"
updateAddressLists()
updateTemplateLists()
$("#address_list").change ->
updateAddresss $("#address_list").val()
$("#templates_list").change ->
updateTemplate $("#templates_list").val()
$("#edit_templates_list").change ->
template = $("#edit_templates_list").val()
if template is "none"
$(".edit_template").fadeOut()
else
updateEditTemplate template
$("#save_template").click ->
data =
template: $("#edit_templates_list").val()
subject: $("#edit_mailtitle").val()
filename: $("#edit_filename").val()
text: $("#edit_mailtext").val()
$.get "./res/php/savetemplate.php", {"data": data}, (data) ->
console.log data
if data is "0"
alert "Edit sucessfully saved."
if $("#edit_templates_list").val() is $("#templates_list").val()
updateTemplate $("#templates_list").val()
else
alert "Error while saving."
$("#create_template").click ->
filename = $("#create_template_name").val()
if filename.substring((filename.length - 4)) isnt ".txt"
alert "The filename has to end with \".txt\""
else
url = "./res/php/fileexists.php?file=templates/#{filename}"
$.get url, status = (data) ->
if data is "1"
data =
template: filename
subject: null
filename: null
text: null
$.get "./res/php/savetemplate.php", {"data": data}, (data) ->
if data is "0"
alert "Template created sucessfully"
$("#templates_list").append """
<option value="#{filename}">#{filename}</option>
"""
$("#edit_templates_list").append """
<option value="#{filename}">#{filename}</option>
"""
$("#remove-template-list").append """
<option value="#{template}">#{template}</option>
"""
else
alert "Error while creating template."
else
alert "A template with that filename already exists"
$("#remove-template-list").change ->
selected = $("#remove-template-list").val()
if selected == "none"
$(".remove_template").fadeOut()
else
$(".remove_template").fadeIn()
$("#remove-template").click ->
selected = $("#remove-template-list").val()
url = "./res/php/deletetemplate.php?template=#{selected}"
$.get url, (data) ->
if data == "0"
alert "Template deleted."
$("#templates_list").empty()
$("#edit_templates_list").empty()
$("#remove-template-list").empty()
$("#edit_templates_list").append """
<option value="none">None Selected</option>
"""
$("#remove-template-list").append """
<option value="none">None Selected</option>
"""
updateTemplateLists()
$(".remove_template").fadeOut()
else
alert "Failed to delete template."
$("#edit-address-list").change ->
selected = $("#edit-address-list").val()
if selected == "none"
$(".edit_address").fadeOut()
else
url = "./res/php/getaddresses.php?list=#{selected}"
$.getJSON url, (data) ->
text = ""
for address in data
text = text + address + "\n"
$("#edit-addresses").val(text)
$(".edit_address").fadeIn()
$("#save-addresses").click ->
data =
list: $("#edit-address-list").val()
addresses: $("#edit-addresses").val().split '\n'
if data.addresses[data.addresses.length - 1] is ""
data.addresses.pop()
$.get "./res/php/savelist.php", {"data": data}, (data) ->
if data == "0"
alert "List sucessfully changed!"
if data.list is $("#address_list")
updateAddresss data.list
else
alert "Error while saving the edit."
$("#create-list").click ->
filename = $("#create-list-name").val()
if filename.substring((filename.length - 4)) isnt ".txt"
alert "The filename has to end with \".txt\""
else
url = "./res/php/fileexists.php?file=lists/#{filename}"
$.get url, status = (data) ->
if data is "1"
data =
list: filename
addresses: [null]
$.get "./res/php/savelist.php", {"data": data}, (data) ->
if data is "0"
alert "Template created sucessfully"
$("#address_list").append """
<option value="#{filename}">#{filename}</option>
"""
$("#edit-address-list").append """
<option value="#{filename}">#{filename}</option>
"""
$("#remove-list-list").append """
<option value="#{filename}">#{filename}</option>
"""
else
alert "Error while creating template."
else
alert "A template with that filename already exists"
$("#remove-list-list").change ->
selected = $("#remove-list-list").val()
if selected == "none"
$(".remove_list").fadeOut()
else
$(".remove_list").fadeIn()
$("#remove-list").click ->
selected = $("#remove-list-list").val()
url = "./res/php/deletelist.php?list=#{selected}"
$.get url, (data) ->
if data == "0"
alert "List deleted."
$("#address_list").empty()
$("#edit-address-list").empty()
$("#remove-list-list").empty()
$("#edit-address-list").append """
<option value="none">None Selected</option>
"""
$("#remove-list-list").append """
<option value="none">None Selected</option>
"""
updateAddressLists()
$(".remove_list").fadeOut()
else
alert "Failed to delete template."
$("#edit-address-list").change ->
selected = $("#edit-address-list").val()
if selected == "none"
$(".edit_address").fadeOut()
else
url = "./res/php/getaddresses.php?list=#{selected}"
$.getJSON url, (data) ->
text = ""
for address in data
text = text + address + "\n"
$("#edit-addresses").val(text)
$(".edit_address").fadeIn()
$(document).ready main
updateTemplateLists = ->
$.getJSON './res/php/gettemplates.php', (data) ->
for templates, template of data.templates
$("#templates_list").append """
<option value="#{template}">#{template}</option>
"""
$("#edit_templates_list").append """
<option value="#{template}">#{template}</option>
"""
$("#remove-template-list").append """
<option value="#{template}">#{template}</option>
"""
updateTemplate data.templates[2]
updateAddresss = (list) ->
url = './res/php/getaddresses.php?list=' + list
$.getJSON url, (data) ->
$("#addresses").empty()
for address in data
$("#addresses").append "<p>#{address}</p>"
updateTemplate = (template) ->
url = './res/php/gettemplate.php?template=' + template
$.getJSON url, (data) ->
$("#mailtitle").val data.subject
$("#filename").val data.filename
$("#mailtext").val data.text
updateEditTemplate = (template) ->
url = './res/php/gettemplate.php?template=' + template
$.getJSON url, (data) ->
$(".edit_template").fadeIn()
$("#edit_mailtitle").val data.subject
$("#edit_filename").val data.filename
$("#edit_mailtext").val data.text
updateAddressLists = ->
$.getJSON './res/php/getlists.php', (data) ->
for lists, list of data.lists
$("#address_list").append """
<option value="#{list}">#{list}</option>
"""
$("#edit-address-list").append """
<option value="#{list}">#{list}</option>
"""
$("#remove-list-list").append """
<option value="#{list}">#{list}</option>
"""
updateAddresss data.lists[2]

11
res/php/deletelist.php Normal file
View file

@ -0,0 +1,11 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$filename = "../../lists/" . $_GET["list"];
if (unlink($filename)) {
echo 0;
} else {
echo 1;
}

View file

@ -0,0 +1,11 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$filename = "../../templates/" . $_GET["template"];
if (unlink($filename)) {
echo 0;
} else {
echo 1;
}

10
res/php/fileexists.php Normal file
View file

@ -0,0 +1,10 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$file = "../../" . $_GET["file"];
if (file_exists($file)) {
echo 0;
} else {
echo 1;
}

13
res/php/getaddresses.php Executable file
View file

@ -0,0 +1,13 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$file = "../../lists/" . $_GET["list"];
$addresses = file($file);
$res = array();
$i = 0;
foreach ($addresses as $address) {
$res[] = substr($address, 0, strlen($address) - 1);
$i++;
}
echo json_encode($res);

21
res/php/getlists.php Normal file
View file

@ -0,0 +1,21 @@
<?php
/**
* FileSpread
* php for json string of lists
*
* Copyright (c) 2016 Marcel Kapfer (mmk2410)
* MIT License
*/
$dir = '../../lists/';
$files = scandir($dir);
$i = 0;
foreach ($files as $file) {
if ( in_array($file, array(".", "..")) ) {
unset($files[$i]);
}
$i++;
}
echo json_encode(array("lists" => $files));

17
res/php/gettemplate.php Normal file
View file

@ -0,0 +1,17 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$file = "../../templates/" . $_GET["template"];
$content = file($file);
$title = substr($content[0], 7);
$filename = substr($content[1], 10);
$text = substr($content[2], 6);
for ($i = 3; $i < count($content); $i++) {
$text = $text . $content[$i];
}
echo json_encode(array("subject" => $title, "filename" => $filename, "text" => $text));

21
res/php/gettemplates.php Normal file
View file

@ -0,0 +1,21 @@
<?php
/**
* FileSpread
* php for json string of templates
*
* Copyright (c) 2016 Marcel Kapfer (mmk2410)
* MIT License
*/
$dir = '../../templates/';
$files = scandir($dir);
$i = 0;
foreach ($files as $file) {
if ( in_array($file, array(".", "..")) ) {
unset($files[$i]);
}
$i++;
}
echo json_encode(array("templates" => $files));

21
res/php/savelist.php Normal file
View file

@ -0,0 +1,21 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$content = $_GET["data"];
$filename = "../../lists/" . $content["list"];
$file = "";
foreach ($content["addresses"] as $address) {
$file = $file . $address . "\n";
}
$handle = fopen($filename, "w");
if (fwrite($handle, $file)) {
echo "0";
} else {
echo "1";
}

19
res/php/savetemplate.php Normal file
View file

@ -0,0 +1,19 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$content = $_GET["data"];
$filename = "../../templates/" . $content["template"];
$file = "Title: " . $content["subject"] . "\n";
$file = $file . "Filename: " . $content["filename"] . "\n";
$file = $file . "Text: " . $content["text"];
$handle = fopen($filename, "w");
if (fwrite($handle, $file)) {
echo "0";
} else {
echo "1";
}

53
res/php/sendmail.php Executable file
View file

@ -0,0 +1,53 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
$ini = pParse_ini_file("../../filespread.ini");
date_default_timezone_set($ini["timezone"]);
require '../../vendor/autoload.php';
$list = "../../lists/" . $_GET["list"];
$template = "../../templates/" . $_GET["template"];
$addresses = file($list);
$content = file($template);
$email = new PHPMailer;
$email->setFrom($ini["email"], $ini["name"]);
$email->Subject = parseSubject($content);
$email->Body = parseText($content);
foreach ($addresses as $address) {
$email->AddAddress($address);
}
$file_to_attach = '../../assets/file.bin';
$filename = parseFilename($content);
$email->AddAttachment($file_to_attach, $filename);
if (!$email->Send()) {
echo "-1";
echo $email->ErrorInfo;
} else {
echo "0";
}
function parseSubject($content) {
return substr($content[0], 7);
}
function parseFilename($content) {
return substr($content[1], 10);
}
function parseText($content) {
$text = substr($content[2], 6);
for ($i = 3; $i < count($content); $i++) {
$text = $text . $content[$i];
}
return $text;
}

10
res/php/upload.php Executable file
View file

@ -0,0 +1,10 @@
<?php
# COPYRIGHT (c) 2016 Marcel Kapfer (mmk2410)
# MIT License
if (0 < $_FILES['userfile']['error']) P{
echo "Error: " . $_FILES['userfile']['error'] . "<br>";
} else {
move_uploaded_file($_FILES['userfile']['tmp_name'], "../../assets/file.bin");
header("Location: ../../");
}