Revision: 8896
http://languagetool.svn.sourceforge.net/languagetool/?rev=8896&view=rev
Author: dnaber
Date: 2013-01-06 14:25:59 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
switch proxy to HTTPS; show error if there's no server response
Modified Paths:
--------------
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/server/proxy.php
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/editor_plugin.js
Modified:
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
===================================================================
---
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
2013-01-06 12:35:08 UTC (rev 8895)
+++
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
2013-01-06 14:25:59 UTC (rev 8896)
@@ -765,7 +765,7 @@
plugin.editor.setProgressState(0);
/* if the server is not accepting requests, let the user know */
- if (request.status != 200 || request.responseText.substr(1, 4)
== 'html')
+ if (request.status != 200 || request.responseText.substr(1, 4)
== 'html' || request.responseText == '')
{
ed.windowManager.alert(
plugin.editor.getLang('AtD.message_server_error', 'There was a problem
communicating with the After the Deadline service. Try again in one minute.') );
return;
Modified:
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/server/proxy.php
===================================================================
---
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/server/proxy.php
2013-01-06 12:35:08 UTC (rev 8895)
+++
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/server/proxy.php
2013-01-06 14:25:59 UTC (rev 8896)
@@ -1,84 +1,25 @@
<?php
-
-// After the Deadline Proxy Script
-// *phear*
-
-// You get the option of hardcoding your API key here. Do this if you don't
want people seeing
-// your key when they do View -> Source.
-$API_KEY = "";
-
-if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
-{
- $postText = trim(file_get_contents('php://input'));
+// LanguageTool Proxy Script
+error_reporting(E_ALL);
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $postText = trim(file_get_contents('php://input'));
+ $postText = urldecode($postText);
+ $postText = html_entity_decode($postText, ENT_COMPAT | ENT_HTML401, "UTF-8");
+
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, "https://languagetool.org");
+ curl_setopt($curl, CURLOPT_PORT, 8081);
+ curl_setopt($curl, CURLOPT_SSLVERSION, 3);
+ curl_setopt($curl, CURLOPT_POST, true);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $postText);
+
+ header("Content-Type: text/xml; charset=utf-8");
+ //for debugging:
+ //header("Content-Type: text/plain");
+
+ curl_exec($curl);
+ curl_close($curl);
+} else {
+ print "Error: this proxy only supports POST";
}
-
-if (strcmp($API_KEY, "") != 0)
-{
- $postText .= '&key=' . $API_KEY;
-}
-
-$postText = str_replace("%26", "&", $postText);
-$postText = str_replace("%20", " ", $postText);
-$postText = str_replace(" ", " ", $postText);
-$postText = html_entity_decode($postText);
-//print "##".$postText;
-
-// I am a vampire
-// I have lost my fangs
-
-$url = $_GET['url'];
-
-/* this function directly from akismet.php by Matt Mullenweg. *props* */
-function AtD_http_post($request, $host, $path, $port = 80)
-{
-
- $http_request = "POST $path HTTP/1.0\r\n";
- // Close is needed to avoid hang in feof() because Java doesn't close the
connection:
- // see http://www.java.net/node/673760
- // and http://www.php.net/manual/de/function.feof.php#95425
- $http_request .= "Connection: close\r\n";
- $http_request .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $http_request .= "Content-Length: " . strlen($request) . "\r\n";
- $http_request .= "User-Agent: AtD-LanguageTool/0.1\r\n";
- $http_request .= "\r\n";
- $http_request .= $request;
-
- $response = '';
- if( false != ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) )
- {
- fwrite($fs, $http_request);
- while ( !feof($fs) )
- {
- $response .= fgets($fs);
- }
- fclose($fs);
- $response = explode("\r\n\r\n", $response, 2);
- }
-
- return $response;
-}
-
-// So I'm sad and I feel lonely
-// So I cry and I'm very angry
-// And I hate some garlic
-// So I'm so no more sad and
-// Ache yeah yeah
-
-// TODO: does not throw error if service cannot be reached
-//$data = AtD_http_post($postText, "service.afterthedeadline.com", $url);
-$data = AtD_http_post($postText, "localhost", "/", 8081);
-//$data = AtD_http_post($postText, "localhost", "/test.xml", 80);
-
-// I am a vampire and I am looking in the city
-// Pretty girls don't look at me
-// Don't look at me
-// Cause I don't have my fangs
-// But I have lost my fangs
-
-header("Content-Type: text/xml");
-echo $data[1];
-
-// print "##".$postText."(".$url.")##";
-
-// -- Antsy Pants, Vampire
?>
Modified:
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/editor_plugin.js
===================================================================
---
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/editor_plugin.js
2013-01-06 12:35:08 UTC (rev 8895)
+++
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/editor_plugin.js
2013-01-06 14:25:59 UTC (rev 8896)
@@ -137,7 +137,7 @@
plugin.editor.setProgressState(0);
/* if the server is not accepting requests, let the user know */
- if (request.status != 200 || request.responseText.substr(1, 4)
== 'html')
+ if (request.status != 200 || request.responseText.substr(1, 4)
== 'html' || request.responseText == '')
{
ed.windowManager.alert(
plugin.editor.getLang('AtD.message_server_error', 'There was a problem
communicating with the After the Deadline service. Try again in one minute.') );
return;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits