aboutsummaryrefslogtreecommitdiffstats
path: root/library/ajaxchat/chat/install.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-18 23:49:39 -0800
committerfriendica <info@friendica.com>2014-01-18 23:49:39 -0800
commit724ad4505628d493b43b4f585512d67dc0b4ee76 (patch)
tree4fb920a79e3dff961a6301ec56ec9f40e91f6af3 /library/ajaxchat/chat/install.php
parent3f7032e542e3c451507fc9266ab3536155c8190f (diff)
downloadvolse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.gz
volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.bz2
volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.zip
add ajaxchat library - needs a lot of integration work to handle decentralisation (e.g. chatroom@website) and zotid w/permissions (e.g. ACL controlled chatrooms); we can also rip out a lot of stuff we don't need.
Diffstat (limited to 'library/ajaxchat/chat/install.php')
-rw-r--r--library/ajaxchat/chat/install.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/library/ajaxchat/chat/install.php b/library/ajaxchat/chat/install.php
new file mode 100644
index 000000000..fd19e1beb
--- /dev/null
+++ b/library/ajaxchat/chat/install.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * @package AJAX_Chat
+ * @author Sebastian Tschan
+ * @copyright (c) Sebastian Tschan
+ * @license Modified MIT License
+ * @link https://blueimp.net/ajax/
+ */
+
+// Show all errors:
+error_reporting(E_ALL);
+
+// Remember to set up the config file to point to your database:
+file_exists('lib/config.php') or die('Failed to load lib/config.php. Did you remember to create a config file based on config.php.example?');
+
+// Path to the chat directory:
+define('AJAX_CHAT_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
+
+// Include custom libraries and initialization code:
+require(AJAX_CHAT_PATH.'lib/custom.php');
+
+// Include Class libraries:
+require(AJAX_CHAT_PATH.'lib/classes.php');
+
+class CustomAJAXChatInstaller extends CustomAJAXChatInterface {
+
+ function &getDataBaseTableCreationQueries() {
+ $queries = array();
+ $index = 0;
+ // Retrieve the queries from the SQL file:
+ $lines = file(AJAX_CHAT_PATH.'chat.sql');
+ // Stop if an error occurs:
+ if(!$lines) {
+ echo 'Failed to load queries from file (chat.sql).';
+ die();
+ }
+ foreach($lines as $line) {
+ if(empty($line)) {
+ continue;
+ }
+ $line = trim($line);
+ if(count($queries) <= $index) {
+ array_push($queries, $line."\n");
+ } else {
+ $queries[$index] .= $line."\n";
+ }
+ // Create a new array item for each query:
+ if(substr($line, -1) == ';') {
+ $index++;
+ }
+ }
+ return $queries;
+ }
+
+ function createDataBaseTables($printSuccessConfirmation=true) {
+ $queries = $this->getDataBaseTableCreationQueries();
+ foreach($queries as $sql) {
+ // Create a new SQL query:
+ $result = $this->db->sqlQuery($sql);
+
+ // Stop if an error occurs:
+ if($result->error()) {
+ echo $result->getError();
+ die();
+ }
+ }
+ if($printSuccessConfirmation) {
+ // Print a success confirmation:
+ echo 'Database tables created successfully - please delete this file (install.php).';
+ }
+ }
+
+}
+
+// Initialize the chat installer:
+$ajaxChatInstaller = new CustomAJAXChatInstaller();
+
+// Create the database tables:
+$ajaxChatInstaller->createDataBaseTables();
+?> \ No newline at end of file