|
1 g_execphp_ajax = new sack(); |
|
2 g_execphp_error_message = ""; |
|
3 g_execphp_retries = 0; |
|
4 g_execphp_max_retries = 3; |
|
5 g_execphp_feature = ""; |
|
6 |
|
7 function ExecPhp_subscribeForFeature(feature) |
|
8 { |
|
9 if (g_execphp_feature.length) |
|
10 g_execphp_feature += ","; |
|
11 g_execphp_feature += feature; |
|
12 } |
|
13 |
|
14 function ExecPhp_fillContainer(container_id, text) |
|
15 { |
|
16 var container = document.getElementById(container_id); |
|
17 try {container.innerHTML = text;} |
|
18 catch (e) {;} |
|
19 } |
|
20 |
|
21 function ExecPhp_markContainer(container_id) |
|
22 { |
|
23 var container = document.getElementById(container_id + "-container"); |
|
24 try {container.style.backgroundColor = "red";} |
|
25 catch (e) {;} |
|
26 |
|
27 } |
|
28 function ExecPhp_ajaxCompletion() |
|
29 { |
|
30 var edit_others_php = ""; |
|
31 var switch_themes = ""; |
|
32 var exec_php = ""; |
|
33 |
|
34 eval(g_execphp_ajax.response); |
|
35 |
|
36 if (!exec_php.length) |
|
37 exec_php = "<p>" + execphpAdminL10n.noUserFound + "</p>"; |
|
38 ExecPhp_fillContainer(execphpAdminL10n.executeArticlesContainer, exec_php); |
|
39 |
|
40 if (!switch_themes.length) |
|
41 switch_themes = "<p>" + execphpAdminL10n.noUserFound + "</p>"; |
|
42 ExecPhp_fillContainer(execphpAdminL10n.widgetsContainer, switch_themes); |
|
43 |
|
44 if (!edit_others_php.length) |
|
45 edit_others_php = "<p>" + execphpAdminL10n.noUserFound + "</p>"; |
|
46 else |
|
47 { |
|
48 heading = execphpAdminL10n.securityAlertHeading; |
|
49 text = execphpAdminL10n.securityAlertText; |
|
50 ExecPhp_setMessage(heading, text); |
|
51 ExecPhp_markContainer(execphpAdminL10n.securityHoleContainer); |
|
52 } |
|
53 ExecPhp_fillContainer(execphpAdminL10n.securityHoleContainer, edit_others_php); |
|
54 } |
|
55 |
|
56 function ExecPhp_ajaxError() |
|
57 { |
|
58 g_execphp_error_message += "<br />" |
|
59 + g_execphp_ajax.responseStatus[0] + " " + g_execphp_ajax.responseStatus[1]; |
|
60 |
|
61 if (g_execphp_retries < g_execphp_max_retries) |
|
62 { |
|
63 // retry call; sometimes it seems that the AJAX admin script returns 404 |
|
64 ++g_execphp_retries; |
|
65 g_execphp_ajax.runAJAX(); |
|
66 } |
|
67 else |
|
68 { |
|
69 // finally give up after certain amount of retries |
|
70 var error_message = "<p>" + execphpAdminL10n.AjaxError + "</p>" |
|
71 + g_execphp_ajax.requestFile + " - " + g_execphp_error_message; |
|
72 |
|
73 ExecPhp_markContainer(execphpAdminL10n.executeArticlesContainer); |
|
74 ExecPhp_fillContainer(execphpAdminL10n.executeArticlesContainer, error_message); |
|
75 |
|
76 ExecPhp_markContainer(execphpAdminL10n.widgetsContainer); |
|
77 ExecPhp_fillContainer(execphpAdminL10n.widgetsContainer, error_message); |
|
78 |
|
79 ExecPhp_markContainer(execphpAdminL10n.securityHoleContainer); |
|
80 ExecPhp_fillContainer(execphpAdminL10n.securityHoleContainer, error_message); |
|
81 |
|
82 g_execphp_error_message = ""; |
|
83 g_execphp_retries = 0; |
|
84 } |
|
85 } |
|
86 |
|
87 function ExecPhp_requestUser() |
|
88 { |
|
89 g_execphp_ajax.setVar("cookie", document.cookie); |
|
90 g_execphp_ajax.setVar("action", execphpAdminL10n.action); |
|
91 g_execphp_ajax.setVar("feature", g_execphp_feature); |
|
92 g_execphp_ajax.requestFile = execphpAdminL10n.requestFile; |
|
93 g_execphp_ajax.onError = ExecPhp_ajaxError; |
|
94 g_execphp_ajax.onCompletion = ExecPhp_ajaxCompletion; |
|
95 g_execphp_ajax.runAJAX(); |
|
96 g_execphp_feature = ""; |
|
97 } |