Distributed Library Project

From YobiWiki
Revision as of 01:01, 9 January 2007 by <bdi>PhilippeTeuwen</bdi> (talk | contribs) (→‎Install)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

From http://www.thoughtcrime.org/software/dlp/index.html

Install

I had to solve 2 issues:
DLP assumes your sql server is on localhost
DLP is broken with Mysql 5

This patch solves both issues, my_remote_sql_server is the host name of your sql server and my_www_server is the host name of the www server as seen by the sql server

diff -Naur dlp.orig/include/database.inc dlp/include/database.inc
--- dlp.orig/include/database.inc       2007-01-08 23:30:36.000000000 +0100
+++ dlp/include/database.inc    2007-01-09 00:52:17.000000000 +0100
@@ -21,7 +21,7 @@
   $context =& getApplicationContext();  
 
   if ($_database_db !== NULL) return $_database_db;
-  $_database_db = mysql_connect("localhost", $context->getDatabaseUser(), $context->getDatabasePassword());
+  $_database_db = mysql_connect("my_remote_sql_server", $context->getDatabaseUser(), $context->getDatabasePassword());
   mysql_select_db($context->getDatabaseName(), $_database_db);
   return $_database_db;
 }
diff -Naur dlp.orig/include/database_schema.inc dlp/include/database_schema.inc
--- dlp.orig/include/database_schema.inc        2004-02-21 02:15:16.000000000 +0100
+++ dlp/include/database_schema.inc     2007-01-09 00:52:00.000000000 +0100
@@ -337,7 +337,7 @@
 function createDatabaseTables($db) {
   $dlp_user_definition = 
     "CREATE TABLE dlp_user (
-       id                MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT, 
+       id                MEDIUMINT NOT NULL AUTO_INCREMENT, 
        verify            VARCHAR(50),
        username          VARCHAR(15) UNIQUE NOT NULL, 
        password          VARCHAR(32) NOT NULL, 
@@ -388,14 +388,14 @@
   
   $dlp_interests_definition =
     "CREATE TABLE dlp_interests ( 
-       id       MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT, 
+       id       MEDIUMINT NOT NULL AUTO_INCREMENT, 
        interest VARCHAR(255) NOT NULL, 
        count    MEDIUMINT DEFAULT '0' NOT NULL, 
        PRIMARY KEY(id), UNIQUE id(id), INDEX(interest(255)))";
   
   $dlp_library_definition =
     "CREATE TABLE dlp_library ( 
-       id             MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT, 
+       id             MEDIUMINT NOT NULL AUTO_INCREMENT, 
        user_id        MEDIUMINT NOT NULL, 
        authorlast     VARCHAR(30) NOT NULL, 
        authorfirst    VARCHAR(30) NOT NULL, 
@@ -411,7 +411,7 @@
   
   $dlp_video_definition =
     "CREATE TABLE dlp_video ( 
-       id             MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT, 
+       id             MEDIUMINT NOT NULL AUTO_INCREMENT, 
        user_id        MEDIUMINT NOT NULL,
        title          VARCHAR(255) NOT NULL, 
        genre          VARCHAR(50) NOT NULL, 
@@ -425,7 +425,7 @@
 
   $dlp_music_definition =
     "CREATE TABLE dlp_music (
-        id             MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT,
+        id             MEDIUMINT NOT NULL AUTO_INCREMENT,
         user_id        MEDIUMINT NOT NULL,
         title          VARCHAR(255) NOT NULL,
         artist         VARCHAR(255) NOT NULL,
@@ -478,7 +478,7 @@
   
   $dlp_lists_definition =
     "CREATE TABLE dlp_lists (
-       id    MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT, 
+       id    MEDIUMINT NOT NULL AUTO_INCREMENT, 
        owner MEDIUMINT NOT NULL, 
         title VARCHAR(255) NOT NULL, 
        created DATE NOT NULL, 
diff -Naur dlp.orig/setup.php dlp/setup.php
--- dlp.orig/setup.php  2004-02-21 02:15:16.000000000 +0100
+++ dlp/setup.php       2007-01-09 00:51:44.000000000 +0100
@@ -275,7 +275,7 @@
     return;
   }
 
-  if (($db = @mysql_connect("localhost", $existingDatabaseUser, $existingDatabasePassword)) == FALSE) {
+  if (($db = @mysql_connect("my_remote_sql_server", $existingDatabaseUser, $existingDatabasePassword)) == FALSE) {
     echo '<span class="error">' . $lang['error_connecting_to_database'] . mysql_error() . '</span><p>';
     displayStepTwo();
     return;
@@ -316,20 +316,20 @@
     return;
   }
 
-  if (($db = @mysql_connect("localhost", $databaseRootUser, $databaseRootPass)) == FALSE) {
+  if (($db = @mysql_connect("my_remote_sql_server", $databaseRootUser, $databaseRootPass)) == FALSE) {
     echo '<span class="error">' . $lang['error_connecting_to_database'] . mysql_error() . '</span><p>';
     displayStepTwo();
     return;
   }
   
   $sql = "CREATE DATABASE $databaseName";
   if (!@mysql_query($sql, $db)) {
     echo '<span class="error">' . $lang['error_creating_database'] . mysql_error() . '</span><p>';
     displayStepTwo();
     return;
   }
     
-  $sql = "GRANT ALL ON $databaseName.* TO $databaseUser@localhost IDENTIFIED BY '$databasePassword'";
+  $sql = "GRANT ALL ON $databaseName.* TO $databaseUser@my_www_server IDENTIFIED BY '$databasePassword'";
   if (!@mysql_query($sql, $db)) {
     echo '<span class="error">' . $lang['error_granting_permissions'] . mysql_error() . '</span><p>';
     displayStepTwo();