! Fixed undefined action in whois online by changing it to use xmlhttp and overriding the default xmlhttp function
Jeremy D

Jeremy D commited on 2012-04-14 12:17:37
Showing 1 changed files, with 19 additions and 2 deletions.

... ...
@@ -5,7 +5,11 @@ function uPMs_hook_actionArray($actionArray)
5 5
 {
6 6
 	global $modSettings;
7 7
 
8
-	$actionArray['unreadpms'] = array('UnreadPMs.php', 'UnreadPMsXML');
8
+	// We will save the original action for use later.
9
+	$modSettings['action_override_xmlhttp_uPMs'] = $actionArray['xmlhttp'];
10
+
11
+	// We will overload the xmlhttp action for our needs.
12
+	$actionArray['xmlhttp'] = array('UnreadPMs.php', 'UPMs_override_action_xmlhttp');
9 13
 }
10 14
 
11 15
 // Adds a hook to the end of loadTheme();
... ...
@@ -27,7 +31,7 @@ function uPMs_hook_load_theme()
27 31
 		{
28 32
 			window.setTimeout(\'funreadPMs();\', ' . $modSettings['unreadPMstimeout'] * 600 . ');
29 33
 
30
-			var oNewPms = getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=unreadpms\');
34
+			var oNewPms = getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=unreadpms\');
31 35
 
32 36
 			if (oNewPms.responseXML)
33 37
 			{
... ...
@@ -48,6 +52,19 @@ function uPMs_hook_general_mod_settings($config_vars)
48 52
 	$config_vars[] = array('int', 'unreadPMstimeout', 'postinput' => $txt['unreadPMstimeout_post']);
49 53
 }
50 54
 
55
+// Overrides the xmlhttp function.
56
+function UPMs_override_action_xmlhttp()
57
+{
58
+	global $modSettings, $sourcedir;
59
+
60
+	if (isset($_GET['sa']) && $_GET['sa'] == 'unreadpms')
61
+		UnreadPMsXML();
62
+
63
+	// Otherwise we will act just like index.php would have.
64
+	require_once($sourcedir . '/' . $modSettings['action_override_xmlhttp_uPMs'][0]);
65
+	return $modSettings['action_override_xmlhttp_uPMs'][1]();
66
+}
67
+
51 68
 // Provides the XML for our javascript to read.
52 69
 function UnreadPMsXML()
53 70
 {
54 71