source: t29-www/en/dev/translation/submit.php @ 189

Last change on this file since 189 was 189, checked in by sven, 14 years ago

Translation-System erweitert, offizieller Upload in Homepage.

  • editor.php ist AJAX-Backend, welches Mail aufsetzt (ziemlich spartanisch)
  • submit.php (ziemlich Quick & Dirty) ist Noscript-Alternative, die komplette Seite auf Text runtergestrippt bearbeitet und an einen dev.technikum29.de-Formmailer verschickt (ansonsten haette man hier noch ein Captcha-System einbauen muessen).
  • tools.js: Ladezeit - editor.js wird bei Aktivierung nachgeladen. Leider geht das mit dem viel groesseren editor.css nicht, weil es den schicken Button rendern muss.
File size: 2.6 KB
Line 
1<?php
2/**
3 * technikum29 translation system submission for AJAX calls.
4 * September 2010, Quick and dirty
5 **/
6
7function get($var, $default=false, $valids=null, $do_not_check_for_bad_input=false) {
8        $value = isset($_POST[$var]) ? $_POST[$var] : $default;
9        if(isset($valids) && !in_array($value, $valids)) $value = $default;
10        if(preg_match('/<(\s*)(script|style)|php|javascript|on[a-z]=/i', $value)) {
11                // bad content! Exit immediately.
12                header("HTTP/1.1 400 Bad Request");
13                print "Illegal value for '$var'. Please contact the staff.";
14                exit();
15        }
16        return $value;
17}
18
19$source = get("source", false, array('ajax'));
20$page = get("page");
21$node = get("node");
22$initial_text = get("initial_text");
23$initial_html = get("initial_html");
24$new_text = get("new_text");
25$new_html = get("new_html");
26
27// spamschutz
28if(!$source) {
29        header("HTTP/1.1 400 Bad Request");
30        print "Only AJAX driven calls are allowed.";
31        exit;
32}
33
34// some intermediates
35$pagename = preg_match("#/([^/]+?)(\.[a-z]+)?$#i", $page, $pageparts) ? $pageparts[1] : false;
36
37// setup mail
38$to = "sven";
39$to .= "@technikum29.de"; // spamschutz (svn!)
40$subject = "t29 translation submission";
41if($pagename) $subject .= " for $pagename";
42$message = <<<HERE
43This ist technikum29 translation system at /en/dev/translation/submit.php form mailer.
44A user translated, using $source,
45        Page: $page
46        Node: $node
47       
48New Plain Text is:
49
50----------------------- START OF USER TEXT ------------------------------------
51$new_text
52------------------------ END OF USER TEXT -------------------------------------
53
54Versus old Plaintext was:
55
56----------------------- START OF OLD TEXT ------------------------------------
57$initial_text
58------------------------ END OF OLD TEXT -------------------------------------
59
60New HTML is:
61
62------------------------ START OF USER HTML -----------------------------------
63$new_html
64------------------------ END OF USER HTML -------------------------------------
65
66Old HTML was:
67
68------------------------ START OF OLD HTML -----------------------------------
69$initial_html
70------------------------ END OF OLD HTML -------------------------------------
71
72Something about the user:
73
74        Referer: $_SERVER[HTTP_REFERER]
75        Agent:   $_SERVER[HTTP_USER_AGENT]
76        IP:      $_SERVER[REMOTE_ADDR]
77HERE;
78
79// Send mail right now
80
81if(mail($to, $subject, $message, "From: t29-translation-www"."@technikum29.de")) {
82        // mail successfully sent
83        print "Mail successfully sent :)";
84} else {
85        // error at mail sending!!!
86        header("HTTP/1.1 500 Internal Server Error");
87        print "I'm sorry, I could not mail your text to the developer team.";
88}
89
90
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License