summaryrefslogtreecommitdiff
path: root/backend/php/src/plugins/plugin.base64.php
Unidiff
Diffstat (limited to 'backend/php/src/plugins/plugin.base64.php') (more/less context) (ignore whitespace changes)
-rw-r--r--backend/php/src/plugins/plugin.base64.php128
1 files changed, 128 insertions, 0 deletions
diff --git a/backend/php/src/plugins/plugin.base64.php b/backend/php/src/plugins/plugin.base64.php
new file mode 100644
index 0000000..323f861
--- a/dev/null
+++ b/backend/php/src/plugins/plugin.base64.php
@@ -0,0 +1,128 @@
1<?php
2class Base64
3{
4 var $sourceObject;
5 var $argv;
6 var $version = '1.0';
7
8 function Version()
9 {
10 return $this->version;
11 }
12
13 function Base64($sourceObject, $argv)
14 {
15 $this->sourceObject = $sourceObject;
16 $this->argv = $argv;
17 }
18
19 function Execute()
20 {
21 return null;
22 }
23
24 function SetupRender()
25 {
26 if (isset($_POST['install_base64']) || isset($_POST['uninstall_base64']))
27 {
28 $this->SetupExecute();
29 }
30 else
31 {
32 $out = "This plugin allows you to install and uninstall a base64 custom function to and from your database.
33 You can then set \$configuration['db_encoding'] = 1 so that all data is transparently encoded and decoded
34 with the minimal overhead possible. Enabling data encoding has quite a few advantages: <br/><br/>
35
36 ";
37 $out .= "<br/><br/><textarea>BASE64 Status";
38 if (Base64::IsBase64FunctionInstalled())
39 {
40 $out .= "\n\tChecking MySQL function....OK!";
41 if (!isset($GLOBALS['configuration']['db_encoding']) || $GLOBALS['configuration']['db_encoding'] != 1)
42 {
43 $out .="\n\tChecking db_encoding status....Failed";
44 $out .= "\n\n---------------------------------------------------";
45 $out .= "\n\$configuration['db_encoding'] is set to 0. Make sure you set the value to 1 to enable data encoding.";
46 }
47 else
48 {
49 $out .="\n\tChecking db_encoding status....OK!";
50 $out .= "\n\nBASE64 Status...OK!";
51 $out .= "\n---------------------------------------------------";
52 }
53 $out .= "</textarea><div style='padding-left:250px;padding-top:10px;'><input type='submit' value='UNINSTALL' name='uninstall_base64'/></div>";
54 }
55 else
56 {
57 $out .= "\n\tChecking MySQL function....NOT INSTALLED";
58 $out .="\n\tChecking db_encoding status ignored";
59 $out .= "\n\n---------------------------------------------------";
60 $out .= "\nClick the INSTALL button below to install the base64 function to your database.";
61 $out .= "</textarea><div style='padding-left:250px;padding-top:10px;'><input type='submit' value='INSTALL' name='install_base64'/></div>";
62 }
63 $out .= "<input type='hidden' name='plugins' value='true'/>";
64 echo $out;
65 }
66 }
67
68 function AuthorPage()
69 {
70 return null;
71 }
72
73
74 function SetupExecute()
75 {
76 $out = '';
77 $connection = Database::Connect();
78 if (isset($_POST['install_base64']) && isset($_POST['install_base64']) == true)
79 {
80 $initialData = file_get_contents('../plugins/base64_install.sql');
81 $statements = explode('|', $initialData);
82 if (sizeof($statements) > 0)
83 {
84 foreach ($statements as $statement)
85 {
86 if (trim($statement) != '')
87 {
88 Database::NonQuery($statement, $connection);
89 }
90 }
91 }
92 $out .= "<textarea>INSTALL SUCCESSFUL\n\n";
93 $out .= "Make sure you set \$configuration[db_encoding] = 1 in the configuration file.</textarea>";
94 }
95 else if (isset($_POST['uninstall_base64']) && $_POST['uninstall_base64'] == true)
96 {
97 $initialData = file_get_contents('../plugins/base64_uninstall.sql');
98 $statements = explode('|', $initialData);
99 if (sizeof($statements) > 0)
100 {
101 foreach ($statements as $statement)
102 {
103 if (trim($statement) != '')
104 {
105 Database::NonQuery($statement, $connection);
106 }
107 }
108 }
109 $out .= "<textarea>UNINSTALL SUCCESSFUL\n\n";
110 $out .= "Make sure you set \$configuration[db_encoding] = 0 in the configuration file.</textarea>";
111 }
112 echo $out;
113 }
114
115 function IsBase64FunctionInstalled()
116 {
117 $sql1 = "show function status where Db='".$GLOBALS['configuration']['db']."' and (Name='BASE64_DECODE' or Name='BASE64_ENCODE')";
118 $sql2 = "show tables like 'base64_data'";
119 $connection = Database::Connect();
120 $result = Database::Query($sql1, $connection);
121 $result2 = Database::Query($sql2, $connection);
122 if ($result == 2 && $result2 == 1)
123 {
124 return true;
125 }
126 return false;
127 }
128}