diff --git a/.hgignore b/.hgignore index 42cd85ac7..f4de35608 100644 --- a/.hgignore +++ b/.hgignore @@ -223,3 +223,6 @@ code/ryzom/server/src/tick_service/tick_service # WebTT temp dir code/ryzom/tools/server/www/webtt/app/tmp code\ryzom\tools\server\ryzom_ams\old + +# AMS ignore +code/ryzom/tools/server/ryzom_ams/www/config.php diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php index af826d084..58ea7b80e 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -14,19 +14,33 @@ class DBLayer{ * Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var) * @param $db String, the name of the databases entry in the $cfg global var. */ - function __construct($db) + function __construct($db, $dbn = null) { - global $cfg; - $dsn = "mysql:"; - $dsn .= "host=". $cfg['db'][$db]['host'].";"; - $dsn .= "dbname=". $cfg['db'][$db]['name'].";"; - $dsn .= "port=". $cfg['db'][$db]['port'].";"; - - $opt = array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC - ); - $this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt); + if ($db != "install"){ + + global $cfg; + $dsn = "mysql:"; + $dsn .= "host=". $cfg['db'][$db]['host'].";"; + $dsn .= "dbname=". $cfg['db'][$db]['name'].";"; + $dsn .= "port=". $cfg['db'][$db]['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt); + } else { + global $cfg; + $dsn = "mysql:"; + $dsn .= "host=". $cfg['db'][$dbn]['host'].";"; + $dsn .= "port=". $cfg['db'][$dbn]['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$_POST['Username'],$_POST['Password'], $opt); + } } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 8f1f9379b..b7c44044e 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -1,6 +1,10 @@ ; This is a sample configuration file ; Comments start with ';', as in php.ini +[install] +login_info = "Please enter your MySQL Username and Password to install the database.This is being loaded because config.php is missing.This process will take about 30 seconds." +login_here = "here" + [dashboard] home_title = "Introduction" home_info = "Welcome to the Ryzom Core - Account Management System" diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.classpath b/code/ryzom/tools/server/ryzom_ams/android_app/.classpath new file mode 100644 index 000000000..c3c8602bb --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.project b/code/ryzom/tools/server/ryzom_ams/android_app/.project new file mode 100644 index 000000000..ba01a3a61 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/.project @@ -0,0 +1,33 @@ + + + MyAndroidApp + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs b/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..2a856569f --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Tue Feb 21 13:19:14 SGT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml b/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml new file mode 100644 index 000000000..70e45aa6c --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java new file mode 100644 index 000000000..b068a863d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package com.mkyong.android; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java new file mode 100644 index 000000000..a451800e7 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java @@ -0,0 +1,25 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.mkyong.android; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class id { + public static final int webView1=0x7f050000; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + } +} diff --git a/code/ryzom/tools/server/ryzom_ams/assets/android_app/info.txt b/code/ryzom/tools/server/ryzom_ams/android_app/info.txt similarity index 100% rename from code/ryzom/tools/server/ryzom_ams/assets/android_app/info.txt rename to code/ryzom/tools/server/ryzom_ams/android_app/info.txt diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg b/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg new file mode 100644 index 000000000..b1cdf17b5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/project.properties b/code/ryzom/tools/server/ryzom_ams/android_app/project.properties new file mode 100644 index 000000000..73fc66102 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-18 diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..8074c4c57 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 000000000..1095584ec Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png new file mode 100644 index 000000000..a07c69fa5 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml b/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml new file mode 100644 index 000000000..41627df16 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml b/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml new file mode 100644 index 000000000..09b33f582 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Ryzom Core AMS + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java b/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java new file mode 100644 index 000000000..260856c52 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java @@ -0,0 +1,22 @@ +package com.mkyong.android; + +import android.app.Activity; +import android.os.Bundle; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +public class MainActivity extends Activity { + + private WebView webView; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + webView = (WebView) findViewById(R.id.webView1); + webView.setWebViewClient(new WebViewClient()); + webView.getSettings().setJavaScriptEnabled(true); + webView.loadUrl("http://shard.ryzomcore.org/ams/index.php"); + + } +} diff --git a/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z b/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z deleted file mode 100644 index ed9366564..000000000 Binary files a/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z and /dev/null differ diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.default.php b/code/ryzom/tools/server/ryzom_ams/www/config.default.php index c559b8b2c..a091ed635 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.default.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.default.php @@ -66,7 +66,7 @@ $MAIL_DIR = "/home/username/mail"; $MAIL_LOG_PATH = "/home/username/mail/cron_mail.log"; //terms of service url location -$TOS_URL ="http://heregoesyourtos.com"; +$TOS_URL ="http://www.gnu.org/licenses/agpl-3.0.html"; //crypt is being used by encrypting & decrypting of the IMAP password of the supportgroups $cfg['crypt']['key'] = 'Sup3rS3cr3tStuff'; @@ -88,8 +88,8 @@ $AMS_CACHEDIR = $AMS_LIB . '/cache'; $SITEBASE = dirname( __FILE__ ) . '/html/' ; //the paths to your website url -$BASE_WEBPATH = 'http://localhost:40917'; -$IMAGELOC_WEBPATH = 'http://localhost:40917/img'; +$BASE_WEBPATH = dirname($_SERVER['PHP_SELF']); +$IMAGELOC_WEBPATH = $_SERVER['REQUEST_URI'].'/img'; $WEBPATH = $BASE_WEBPATH . '/index.php'; $INGAME_WEBPATH = $BASE_WEBPATH . '/index.php'; $CONFIG_PATH = dirname( __FILE__ ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index 40b4e6535..50d8227be 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -13,8 +13,14 @@ //load required pages and turn error reporting on/off error_reporting(E_ALL); ini_set('display_errors', 'on'); -require( '../config.php' ); -require( '../../ams_lib/libinclude.php' ); +require_once( '../../ams_lib/libinclude.php' ); +if (!@include '../config.php') { + //if config doesnt exist run setup + require( 'installer/libsetup.php' ); +} else { + //if config exists then include it + require( '../config.php' ); +} session_start(); //Decide what page to load diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php new file mode 100644 index 000000000..9118afb76 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php @@ -0,0 +1,621 @@ +executeWithoutParams($sql); + + //SETUP THE AMS_LIB DB + $dbl = new DBLayer("install", "lib"); + + $sql = " + CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`; + USE `" . $cfg['db']['lib']['name'] ."`; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ams_querycache`; + + CREATE TABLE ams_querycache ( + `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , + `type` VARCHAR( 64 ) NOT NULL , + `query` VARCHAR( 512 ) NOT NULL, + `db` VARCHAR( 80 ) NOT NULL + ); + + -- ----------------------------------------------------------------------------------------------------------------------- + -- ----------------------------------------------------------------------------------------------------------------------- + + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_category` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ( + `TCategoryId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(45) NOT NULL , + PRIMARY KEY (`TCategoryId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_user` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ( + `TUserId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , + `Permission` INT(3) NOT NULL DEFAULT 1 , + `ExternId` INT(10) UNSIGNED NOT NULL , + PRIMARY KEY (`TUserId`) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ( + `TId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Title` VARCHAR(120) NOT NULL , + `Status` INT NULL DEFAULT 0 , + `Queue` INT NULL DEFAULT 0 , + `Ticket_Category` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Priority` INT(3) NULL DEFAULT 0 , + PRIMARY KEY (`TId`) , + INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , + INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , + CONSTRAINT `fk_ticket_ticket_category` + FOREIGN KEY (`Ticket_Category` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`TCategoryId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`assigned` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ( + `Ticket` INT UNSIGNED NOT NULL , + `User` INT UNSIGNED NOT NULL , + INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , + PRIMARY KEY (`Ticket`, `User`) , + INDEX `fk_assigned_ams_user_idx` (`User` ASC) , + CONSTRAINT `fk_assigned_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_assigned_ams_user` + FOREIGN KEY (`User` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tag` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ( + `TagId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Value` VARCHAR(60) NOT NULL , + PRIMARY KEY (`TagId`) , + UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tagged` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ( + `Ticket` INT UNSIGNED NOT NULL , + `Tag` INT UNSIGNED NOT NULL , + PRIMARY KEY (`Ticket`, `Tag`) , + INDEX `fk_tagged_tag_idx` (`Tag` ASC) , + CONSTRAINT `fk_tagged_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_tagged_tag` + FOREIGN KEY (`Tag` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`tag` (`TagId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_content` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ( + `TContentId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Content` TEXT NULL , + PRIMARY KEY (`TContentId`) ) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ( + `TReplyId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Content` INT UNSIGNED NOT NULL , + `Timestamp` TIMESTAMP NULL , + `Hidden` TINYINT(1) NULL DEFAULT 0 , + PRIMARY KEY (`TReplyId`) , + INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , + INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , + INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , + CONSTRAINT `fk_ticket_reply_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ticket_content` + FOREIGN KEY (`Content` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_content` (`TContentId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ( + `TGroupId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Title` VARCHAR(80) NOT NULL , + PRIMARY KEY (`TGroupId`) , + UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`in_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ( + `Ticket_Group` INT UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + PRIMARY KEY (`Ticket_Group`, `Ticket`) , + INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , + INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , + CONSTRAINT `fk_in_group_ticket_group` + FOREIGN KEY (`Ticket_Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_group` (`TGroupId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_group_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_log` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ( + `TLogId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Query` VARCHAR(255) NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT(10) UNSIGNED NULL , + PRIMARY KEY (`TLogId`) , + INDEX `fk_ticket_log_ticket1` (`Ticket` ASC) , + INDEX `fk_ticket_log_ticket_user1` (`Author` ASC) , + CONSTRAINT `fk_ticket_log_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_log_ticket_user1` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + INSERT IGNORE INTO `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`Name`) VALUES ('Uncategorized'),('Hacking'),('Ingame-Bug'),('Website-Bug'),('Installation'); + + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`support_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ( + `SGroupId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(22) NOT NULL , + `Tag` VARCHAR(7) NOT NULL , + `GroupEmail` VARCHAR(45) NULL , + `IMAP_MailServer` VARCHAR(60) NULL , + `IMAP_Username` VARCHAR(45) NULL , + `IMAP_Password` VARCHAR(90) NULL , + PRIMARY KEY (`SGroupId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) , + UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`in_support_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ( + `User` INT(10) UNSIGNED NOT NULL , + `Group` INT(10) UNSIGNED NOT NULL , + INDEX `fk_in_support_group_ticket_user1` (`User` ASC) , + INDEX `fk_in_support_group_support_group1` (`Group` ASC) , + CONSTRAINT `fk_in_support_group_ticket_user1` + FOREIGN KEY (`User` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_support_group_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`forwarded` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ( + `Group` INT(10) UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + INDEX `fk_forwarded_support_group1` (`Group` ASC) , + INDEX `fk_forwarded_ticket1` (`Ticket` ASC) , + CONSTRAINT `fk_forwarded_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_forwarded_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`email` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ( + `MailId` INT NOT NULL AUTO_INCREMENT , + `Recipient` VARCHAR(50) NULL , + `Subject` VARCHAR(60) NULL , + `Body` VARCHAR(400) NULL , + `Status` VARCHAR(45) NULL , + `Attempts` VARCHAR(45) NULL DEFAULT 0 , + `UserId` INT(10) UNSIGNED NULL , + `MessageId` VARCHAR(45) NULL , + `TicketId` INT UNSIGNED NULL , + `Sender` INT(10) UNSIGNED NULL , + PRIMARY KEY (`MailId`) , + INDEX `fk_email_ticket_user2` (`UserId` ASC) , + INDEX `fk_email_ticket1` (`TicketId` ASC) , + INDEX `fk_email_support_group1` (`Sender` ASC) , + CONSTRAINT `fk_email_ticket_user2` + FOREIGN KEY (`UserId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_ticket1` + FOREIGN KEY (`TicketId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_support_group1` + FOREIGN KEY (`Sender` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_info` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ( + `TInfoId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Ticket` INT UNSIGNED NOT NULL , + `ShardId` INT NULL , + `UserPosition` VARCHAR(65) NULL , + `ViewPosition` VARCHAR(65) NULL , + `ClientVersion` VARCHAR(65) NULL , + `PatchVersion` VARCHAR(65) NULL , + `ServerTick` VARCHAR(40) NULL , + `ConnectState` VARCHAR(40) NULL , + `LocalAddress` VARCHAR(70) NULL , + `Memory` VARCHAR(60) NULL , + `OS` VARCHAR(120) NULL , + `Processor` VARCHAR(120) NULL , + `CPUID` VARCHAR(50) NULL , + `CpuMask` VARCHAR(50) NULL , + `HT` VARCHAR(35) NULL , + `NeL3D` VARCHAR(120) NULL , + `PlayerName` VARCHAR(45) NULL , + `UserId` INT NULL , + `TimeInGame` VARCHAR(50) NULL , + PRIMARY KEY (`TInfoId`) , + INDEX `fk_ticket_info_ticket1` (`Ticket` ASC) , + CONSTRAINT `fk_ticket_info_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + GRANT ALL ON `" . $cfg['db']['lib']['name'] ."`.* TO `" . $cfg['db']['lib']['user'] ."`@localhost; + "; + $dbl->executeWithoutParams($sql); + print "The Lib & Web database were correctly installed! "; + + //SETUP THE SHARD DB + $dbs = new DBLayer("install", "shard"); + $sql = " + CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['shard']['name'] ."`; + USE `". $cfg['db']['shard']['name'] . "`; + + CREATE TABLE IF NOT EXISTS `domain` ( + `domain_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `domain_name` varchar(32) NOT NULL DEFAULT '', + `status` enum('ds_close','ds_dev','ds_restricted','ds_open') NOT NULL DEFAULT 'ds_dev', + `patch_version` int(10) unsigned NOT NULL DEFAULT '0', + `backup_patch_url` varchar(255) DEFAULT NULL, + `patch_urls` text, + `login_address` varchar(255) NOT NULL DEFAULT '', + `session_manager_address` varchar(255) NOT NULL DEFAULT '', + `ring_db_name` varchar(255) NOT NULL DEFAULT '', + `web_host` varchar(255) NOT NULL DEFAULT '', + `web_host_php` varchar(255) NOT NULL DEFAULT '', + `description` varchar(200) DEFAULT NULL, + PRIMARY KEY (`domain_id`), + UNIQUE KEY `name_idx` (`domain_name`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; + + INSERT INTO `domain` (`domain_id`, `domain_name`, `status`, `patch_version`, `backup_patch_url`, `patch_urls`, `login_address`, `session_manager_address`, `ring_db_name`, `web_host`, `web_host_php`, `description`) VALUES + (12, 'ryzom_open', 'ds_open', 610, 'http://127.0.0.1:23001', NULL, '127.0.0.1:49998', '127.0.0.1:49999', 'ring_open', '127.0.0.1:30000', '127.0.0.1:40916', 'Open Domain'); + + CREATE TABLE IF NOT EXISTS `permission` ( + `UId` int(10) unsigned NOT NULL DEFAULT '0', + `ClientApplication` char(64) NOT NULL DEFAULT 'ryzom', + `ShardId` int(10) NOT NULL DEFAULT '-1', + `AccessPrivilege` set('OPEN','DEV','RESTRICTED') NOT NULL DEFAULT 'OPEN', + `prim` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`prim`), + KEY `UIDIndex` (`UId`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + + CREATE TABLE IF NOT EXISTS `shard` ( + `ShardId` int(10) NOT NULL DEFAULT '0', + `domain_id` int(11) unsigned NOT NULL DEFAULT '0', + `WsAddr` varchar(64) DEFAULT NULL, + `NbPlayers` int(10) unsigned DEFAULT '0', + `Name` varchar(255) DEFAULT 'unknown shard', + `Online` tinyint(1) unsigned DEFAULT '0', + `ClientApplication` varchar(64) DEFAULT 'ryzom', + `Version` varchar(64) NOT NULL DEFAULT '', + `PatchURL` varchar(255) NOT NULL DEFAULT '', + `DynPatchURL` varchar(255) NOT NULL DEFAULT '', + `FixedSessionId` int(11) unsigned NOT NULL DEFAULT '0', + `State` enum('ds_close','ds_dev','ds_restricted','ds_open') NOT NULL DEFAULT 'ds_dev', + `MOTD` text NOT NULL, + `prim` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`prim`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contains all shards informations for login system' AUTO_INCREMENT=31 ; + + INSERT INTO `shard` (`ShardId`, `domain_id`, `WsAddr`, `NbPlayers`, `Name`, `Online`, `ClientApplication`, `Version`, `PatchURL`, `DynPatchURL`, `FixedSessionId`, `State`, `MOTD`, `prim`) VALUES + (302, 12, '127.0.0.1', 0, 'Open Shard', 0, 'ryzom_open', '', '', '', 0, 'ds_dev', '', 30); + + CREATE TABLE IF NOT EXISTS `user` ( + `UId` int(10) NOT NULL AUTO_INCREMENT, + `Login` varchar(64) NOT NULL DEFAULT '', + `Password` varchar(13) DEFAULT NULL, + `ShardId` int(10) NOT NULL DEFAULT '-1', + `State` enum('Offline','Online') NOT NULL DEFAULT 'Offline', + `Privilege` varchar(255) NOT NULL DEFAULT '', + `GroupName` varchar(255) NOT NULL DEFAULT '', + `FirstName` varchar(255) NOT NULL DEFAULT '', + `LastName` varchar(255) NOT NULL DEFAULT '', + `Birthday` varchar(32) NOT NULL DEFAULT '', + `Gender` tinyint(1) unsigned NOT NULL DEFAULT '0', + `Country` char(2) NOT NULL DEFAULT '', + `Email` varchar(255) NOT NULL DEFAULT '', + `Address` varchar(255) NOT NULL DEFAULT '', + `City` varchar(100) NOT NULL DEFAULT '', + `PostalCode` varchar(10) NOT NULL DEFAULT '', + `USState` char(2) NOT NULL DEFAULT '', + `Chat` char(2) NOT NULL DEFAULT '0', + `BetaKeyId` int(10) unsigned NOT NULL DEFAULT '0', + `CachedCoupons` varchar(255) NOT NULL DEFAULT '', + `ProfileAccess` varchar(45) DEFAULT NULL, + `Level` int(2) NOT NULL DEFAULT '0', + `CurrentFunds` int(4) NOT NULL DEFAULT '0', + `IdBilling` varchar(255) NOT NULL DEFAULT '', + `Community` char(2) NOT NULL DEFAULT '--', + `Newsletter` tinyint(1) NOT NULL DEFAULT '1', + `Account` varchar(64) NOT NULL DEFAULT '', + `ChoiceSubLength` tinyint(2) NOT NULL DEFAULT '0', + `CurrentSubLength` varchar(255) NOT NULL DEFAULT '0', + `ValidIdBilling` int(4) NOT NULL DEFAULT '0', + `GMId` int(4) NOT NULL DEFAULT '0', + `ExtendedPrivilege` varchar(128) NOT NULL DEFAULT '', + `ToolsGroup` varchar(20) NOT NULL DEFAULT '', + `Unsubscribe` date NOT NULL DEFAULT '0000-00-00', + `SubDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `SubIp` varchar(20) NOT NULL DEFAULT '', + `SecurePassword` varchar(32) NOT NULL DEFAULT '', + `LastInvoiceEmailCheck` date NOT NULL DEFAULT '0000-00-00', + `FromSource` varchar(8) NOT NULL DEFAULT '', + `ValidMerchantCode` varchar(13) NOT NULL DEFAULT '', + `PBC` tinyint(1) NOT NULL DEFAULT '0', + `ApiKeySeed` varchar(8) DEFAULT NULL, + PRIMARY KEY (`UId`), + KEY `LoginIndex` (`Login`), + KEY `GroupIndex` (`GroupName`), + KEY `ToolsGroup` (`ToolsGroup`), + KEY `CurrentSubLength` (`CurrentSubLength`), + KEY `Community` (`Community`), + KEY `Email` (`Email`), + KEY `GMId` (`GMId`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contains all users informations for login system' AUTO_INCREMENT=1 ; + + GRANT ALL ON `" . $cfg['db']['shard']['name'] ."`.* TO `" . $cfg['db']['shard']['user'] ."`@localhost; + "; + $dbs->executeWithoutParams($sql); + print "The shard database was correctly installed! "; + + + //Now create an admin account! + $hashpass = crypt("admin", Users::generateSALT()); + $params = array( + 'name' => "admin", + 'pass' => $hashpass, + 'mail' => "admin@admin.com", + 'permission' => 3, + 'lang' => "en" + ); + try{ + $dbw = new DBLayer("web"); + $user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Permission, Language) VALUES (:name, :pass, :mail, :permission, :lang)",$params); + Users::createUser($params, $user_id); + $dbl = new DBLayer("lib"); + $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); + print "The admin account is created, you can login with id: admin, pass: admin!"; + }catch (PDOException $e){ + print "There was an error while creating the admin account! "; + } + + + //copy config.default.php to config.php! + if (!file_exists('../config.php')) { + if (!copy('../config.default.php', '../config.php')) { + echo "failed to copy ../config.php ...\n"; + } + } + echo 'Reload! '; + exit; + + + + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print "There was an error while installing"; + print_r($e); + } + } + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php deleted file mode 100644 index 0130f1a65..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ /dev/null @@ -1,481 +0,0 @@ -executeWithoutParams($sql); - - //SETUP THE AMS_LIB DB - $dbl = new DBLayer("lib"); - $sql = " - CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`; - USE `" . $cfg['db']['lib']['name'] ."`; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ams_querycache`; - - CREATE TABLE ams_querycache ( - `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `type` VARCHAR( 64 ) NOT NULL , - `query` VARCHAR( 512 ) NOT NULL, - `db` VARCHAR( 80 ) NOT NULL - ); - - -- ----------------------------------------------------------------------------------------------------------------------- - -- ----------------------------------------------------------------------------------------------------------------------- - - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_category` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ( - `TCategoryId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Name` VARCHAR(45) NOT NULL , - PRIMARY KEY (`TCategoryId`) , - UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_user` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ( - `TUserId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , - `Permission` INT(3) NOT NULL DEFAULT 1 , - `ExternId` INT(10) UNSIGNED NOT NULL , - PRIMARY KEY (`TUserId`) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ( - `TId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Timestamp` TIMESTAMP NOT NULL , - `Title` VARCHAR(120) NOT NULL , - `Status` INT NULL DEFAULT 0 , - `Queue` INT NULL DEFAULT 0 , - `Ticket_Category` INT UNSIGNED NOT NULL , - `Author` INT UNSIGNED NOT NULL , - `Priority` INT(3) NULL DEFAULT 0 , - PRIMARY KEY (`TId`) , - INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , - INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , - CONSTRAINT `fk_ticket_ticket_category` - FOREIGN KEY (`Ticket_Category` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`TCategoryId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_ams_user` - FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`assigned` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ( - `Ticket` INT UNSIGNED NOT NULL , - `User` INT UNSIGNED NOT NULL , - INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , - PRIMARY KEY (`Ticket`, `User`) , - INDEX `fk_assigned_ams_user_idx` (`User` ASC) , - CONSTRAINT `fk_assigned_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_assigned_ams_user` - FOREIGN KEY (`User` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`tag` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ( - `TagId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Value` VARCHAR(60) NOT NULL , - PRIMARY KEY (`TagId`) , - UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`tagged` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ( - `Ticket` INT UNSIGNED NOT NULL , - `Tag` INT UNSIGNED NOT NULL , - PRIMARY KEY (`Ticket`, `Tag`) , - INDEX `fk_tagged_tag_idx` (`Tag` ASC) , - CONSTRAINT `fk_tagged_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_tagged_tag` - FOREIGN KEY (`Tag` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`tag` (`TagId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_content` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ( - `TContentId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Content` TEXT NULL , - PRIMARY KEY (`TContentId`) ) - ENGINE = InnoDB - DEFAULT CHARACTER SET = utf8; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ( - `TReplyId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Ticket` INT UNSIGNED NOT NULL , - `Author` INT UNSIGNED NOT NULL , - `Content` INT UNSIGNED NOT NULL , - `Timestamp` TIMESTAMP NULL , - `Hidden` TINYINT(1) NULL DEFAULT 0 , - PRIMARY KEY (`TReplyId`) , - INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , - INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , - INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , - CONSTRAINT `fk_ticket_reply_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_reply_ams_user` - FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_reply_ticket_content` - FOREIGN KEY (`Content` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_content` (`TContentId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ( - `TGroupId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Title` VARCHAR(80) NOT NULL , - PRIMARY KEY (`TGroupId`) , - UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`in_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ( - `Ticket_Group` INT UNSIGNED NOT NULL , - `Ticket` INT UNSIGNED NOT NULL , - PRIMARY KEY (`Ticket_Group`, `Ticket`) , - INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , - INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , - CONSTRAINT `fk_in_group_ticket_group` - FOREIGN KEY (`Ticket_Group` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_group` (`TGroupId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_in_group_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_log` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ( - `TLogId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Timestamp` TIMESTAMP NOT NULL , - `Query` VARCHAR(255) NOT NULL , - `Ticket` INT UNSIGNED NOT NULL , - `Author` INT(10) UNSIGNED NULL , - PRIMARY KEY (`TLogId`) , - INDEX `fk_ticket_log_ticket1` (`Ticket` ASC) , - INDEX `fk_ticket_log_ticket_user1` (`Author` ASC) , - CONSTRAINT `fk_ticket_log_ticket1` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_log_ticket_user1` - FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - INSERT IGNORE INTO `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`Name`) VALUES ('Uncategorized'),('Hacking'),('Ingame-Bug'),('Website-Bug'),('Installation'); - - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`support_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ( - `SGroupId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , - `Name` VARCHAR(22) NOT NULL , - `Tag` VARCHAR(7) NOT NULL , - `GroupEmail` VARCHAR(45) NULL , - `IMAP_MailServer` VARCHAR(60) NULL , - `IMAP_Username` VARCHAR(45) NULL , - `IMAP_Password` VARCHAR(90) NULL , - PRIMARY KEY (`SGroupId`) , - UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) , - UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`in_support_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ( - `User` INT(10) UNSIGNED NOT NULL , - `Group` INT(10) UNSIGNED NOT NULL , - INDEX `fk_in_support_group_ticket_user1` (`User` ASC) , - INDEX `fk_in_support_group_support_group1` (`Group` ASC) , - CONSTRAINT `fk_in_support_group_ticket_user1` - FOREIGN KEY (`User` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_in_support_group_support_group1` - FOREIGN KEY (`Group` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`forwarded` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ( - `Group` INT(10) UNSIGNED NOT NULL , - `Ticket` INT UNSIGNED NOT NULL , - INDEX `fk_forwarded_support_group1` (`Group` ASC) , - INDEX `fk_forwarded_ticket1` (`Ticket` ASC) , - CONSTRAINT `fk_forwarded_support_group1` - FOREIGN KEY (`Group` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) - ON DELETE CASCADE - ON UPDATE NO ACTION, - CONSTRAINT `fk_forwarded_ticket1` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`email` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ( - `MailId` INT NOT NULL AUTO_INCREMENT , - `Recipient` VARCHAR(50) NULL , - `Subject` VARCHAR(60) NULL , - `Body` VARCHAR(400) NULL , - `Status` VARCHAR(45) NULL , - `Attempts` VARCHAR(45) NULL DEFAULT 0 , - `UserId` INT(10) UNSIGNED NULL , - `MessageId` VARCHAR(45) NULL , - `TicketId` INT UNSIGNED NULL , - `Sender` INT(10) UNSIGNED NULL , - PRIMARY KEY (`MailId`) , - INDEX `fk_email_ticket_user2` (`UserId` ASC) , - INDEX `fk_email_ticket1` (`TicketId` ASC) , - INDEX `fk_email_support_group1` (`Sender` ASC) , - CONSTRAINT `fk_email_ticket_user2` - FOREIGN KEY (`UserId` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_email_ticket1` - FOREIGN KEY (`TicketId` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_email_support_group1` - FOREIGN KEY (`Sender` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_info` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_info` ( - `TInfoId` INT UNSIGNED NOT NULL AUTO_INCREMENT , - `Ticket` INT UNSIGNED NOT NULL , - `ShardId` INT NULL , - `UserPosition` VARCHAR(65) NULL , - `ViewPosition` VARCHAR(65) NULL , - `ClientVersion` VARCHAR(65) NULL , - `PatchVersion` VARCHAR(65) NULL , - `ServerTick` VARCHAR(40) NULL , - `ConnectState` VARCHAR(40) NULL , - `LocalAddress` VARCHAR(70) NULL , - `Memory` VARCHAR(60) NULL , - `OS` VARCHAR(120) NULL , - `Processor` VARCHAR(120) NULL , - `CPUID` VARCHAR(50) NULL , - `CpuMask` VARCHAR(50) NULL , - `HT` VARCHAR(35) NULL , - `NeL3D` VARCHAR(120) NULL , - `PlayerName` VARCHAR(45) NULL , - `UserId` INT NULL , - `TimeInGame` VARCHAR(50) NULL , - PRIMARY KEY (`TInfoId`) , - INDEX `fk_ticket_info_ticket1` (`Ticket` ASC) , - CONSTRAINT `fk_ticket_info_ticket1` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - "; - $dbl->executeWithoutParams($sql); - print "The Lib & Web database were correctly installed! "; - - //Now create an admin account! - $hashpass = crypt("admin", Users::generateSALT()); - $params = array( - 'name' => "admin", - 'pass' => $hashpass, - 'mail' => "admin@admin.com", - 'permission' => 3, - 'lang' => "en" - ); - try{ - $dbw = new DBLayer("web"); - $user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Permission, Language) VALUES (:name, :pass, :mail, :permission, :lang)",$params); - Users::createUser($params, $user_id); - $dbl = new DBLayer("lib"); - $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); - print "The admin account is created, you can login with id: admin, pass: admin!"; - }catch (PDOException $e){ - print "There was an error while creating the admin account! "; - } - - - - - - - }catch (PDOException $e) { - //go to error page or something, because can't access website db - print "There was an error while installing"; - print_r($e); - } - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl new file mode 100644 index 000000000..46d2996d5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install.tpl @@ -0,0 +1,43 @@ +{extends file="layout.tpl"} +{block name=content} + + + + + + + + + + + {$login_info} + + + + + + + + + + + + + + + + Run Install + + + + + {if isset($login_error) and $login_error eq "TRUE"} + + × + {$login_error_message} + + {/if} + + +{/block} +
+ + Run Install +