<?php

require_once dirname(__FILE__) . '/../include/use_type.php';
require_once dirname(__FILE__) . '/../include/check_method.php';
require dirname(__FILE__) . '/../include/processCookie.php';
if ($LOGIN_DATA['user_id'] && check_method(array('GET', 'POST')) == 'POST') {
    $successful_submit = false;
    if ($_POST['name'] && $_POST['price'] && $_POST['source_license'] && $_POST['content_license'] && ($_POST['source_file'] || $_POST['source_control'])) {
        require dirname(__FILE__) . '/../include/emailclass.php';
        $mail = new sendmail();
        $mail->gpg_add_key('0x0DD626E6');
        $mail->gpg_set_type(GPG_ASYMMETRIC);
        $mail->gpg_set_sign(1);
        $mail->gpg_set_signing_key('0x0DD626E6');
        $mail->gpg_set_homedir('/home/apt/.gnupg/');
        $mail->sender("*****@*****.**");
        $mail->from($LOGIN_DATA['email']);
        $mail->add_to('*****@*****.**');
        $mail->subject('TVE Application Submission: ' . $_POST['name']);
        if ($_FILES['source_file']) {
            $mail->attachment($_FILES['source_file']['tmp_name'], $_FILES['source_file']['type'], $_FILES['source_file']['name']);
        }
        foreach ($_POST as $key => $val) {
            if ($key == 'source_file') {
                continue;
            }
            $mail->body($key . ': ' . $val . "\n");
        }
        $mail->body('User: '******'user_id']);
        $successful_submit = $mail->send();
    }