From ef68436ac04da078ffdcacd7e1f785473a303d45 Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Sun, 02 Oct 2011 23:56:18 +0000 Subject: First version of the newly restructured repository --- (limited to 'backend/php/src/plugins/plugin.base64.php') 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 @@ +version; + } + + function Base64($sourceObject, $argv) + { + $this->sourceObject = $sourceObject; + $this->argv = $argv; + } + + function Execute() + { + return null; + } + + function SetupRender() + { + if (isset($_POST['install_base64']) || isset($_POST['uninstall_base64'])) + { + $this->SetupExecute(); + } + else + { + $out = "This plugin allows you to install and uninstall a base64 custom function to and from your database. + You can then set \$configuration['db_encoding'] = 1 so that all data is transparently encoded and decoded + with the minimal overhead possible. Enabling data encoding has quite a few advantages:

+ + "; + $out .= "

"; + } + else + { + $out .= "\n\tChecking MySQL function....NOT INSTALLED"; + $out .= "\n\tChecking db_encoding status ignored"; + $out .= "\n\n---------------------------------------------------"; + $out .= "\nClick the INSTALL button below to install the base64 function to your database."; + $out .= "
"; + } + $out .= ""; + echo $out; + } + } + + function AuthorPage() + { + return null; + } + + + function SetupExecute() + { + $out = ''; + $connection = Database::Connect(); + if (isset($_POST['install_base64']) && isset($_POST['install_base64']) == true) + { + $initialData = file_get_contents('../plugins/base64_install.sql'); + $statements = explode('|', $initialData); + if (sizeof($statements) > 0) + { + foreach ($statements as $statement) + { + if (trim($statement) != '') + { + Database::NonQuery($statement, $connection); + } + } + } + $out .= ""; + } + else if (isset($_POST['uninstall_base64']) && $_POST['uninstall_base64'] == true) + { + $initialData = file_get_contents('../plugins/base64_uninstall.sql'); + $statements = explode('|', $initialData); + if (sizeof($statements) > 0) + { + foreach ($statements as $statement) + { + if (trim($statement) != '') + { + Database::NonQuery($statement, $connection); + } + } + } + $out .= ""; + } + echo $out; + } + + function IsBase64FunctionInstalled() + { + $sql1 = "show function status where Db='".$GLOBALS['configuration']['db']."' and (Name='BASE64_DECODE' or Name='BASE64_ENCODE')"; + $sql2 = "show tables like 'base64_data'"; + $connection = Database::Connect(); + $result = Database::Query($sql1, $connection); + $result2 = Database::Query($sql2, $connection); + if ($result == 2 && $result2 == 1) + { + return true; + } + return false; + } +} -- cgit v0.9.0.2