function cityprefs_install()
{
    global $session;
    require_once "lib/tabledescriptor.php";
    $cityprefs = array('cityid' => array('name' => 'cityid', 'type' => 'int unsigned', 'extra' => 'not null auto_increment'), 'module' => array('name' => 'module', 'type' => 'varchar(255)', 'extra' => 'not null'), 'cityname' => array('name' => 'cityname', 'type' => 'varchar(255)', 'extra' => 'not null'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'cityid'), 'index-cityid' => array('name' => 'cityid', 'type' => 'index', 'columns' => 'cityid'), 'index-module' => array('name' => 'module', 'type' => 'index', 'columns' => 'module'), 'index-cityname' => array('name' => 'cityname', 'type' => 'index', 'columns' => 'cityname'));
    synctable(db_prefix('cityprefs'), $cityprefs, true);
    if (!is_module_active('cityprefs')) {
        if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
            output_notl("`4Installing cityprefs Module.`n");
        }
        $sql = "INSERT INTO " . db_prefix("cityprefs") . " (module,cityname) VALUES ('none','" . getsetting("villagename", LOCATION_FIELDS) . "')";
        db_query($sql);
        $vloc = array();
        $vloc = modulehook("validlocation", $vloc);
        ksort($vloc);
        reset($vloc);
        foreach ($vloc as $loc => $val) {
            $sql = "select modulename from " . db_prefix("module_settings") . " where value='" . addslashes($loc) . "' and setting='villagename'";
            $result = db_query($sql);
            $row = db_fetch_assoc($result);
            $sql = "INSERT INTO " . db_prefix("cityprefs") . " (module,cityname) VALUES ('" . $row['modulename'] . "','" . addslashes($loc) . "')";
            db_query($sql);
        }
    } else {
        if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
            output("`4Updating cityprefs Module.`n");
        }
    }
    module_addhook("superuser");
    module_addhook("changesetting");
    return true;
}
function bugtracker_install()
{
    $bugs = array('id' => array('name' => 'creatureid', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'status' => array('name' => 'status', 'type' => 'text'), 'public' => array('name' => 'public', 'type' => 'bool'), 'info' => array('name' => 'info', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('bugs'), $bugs, true);
    return true;
}
function serverloadperpage_install()
{
    $performancepage = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'page' => array('name' => 'page', 'type' => 'text'), 'totaltime' => array('name' => 'totaltime', 'type' => 'double unsigned'), 'totalpages' => array('name' => 'totalpages', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('performancepage'), $performancepage, true);
    module_addhook("footer-performance");
    return true;
}
function analytics_install()
{
    $expchars = array('acctid' => array('name' => 'acctid', 'type' => 'int(11) unsigned'), 'dateexpired' => array('name' => 'dateexpired', 'type' => 'datetime'), 'datecreated' => array('name' => 'datecreated', 'type' => 'datetime'), 'donation' => array('name' => 'donation', 'default' => '0', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'acctid'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('expchars'), $expchars, true);
    module_addhook("superuser");
    module_addhook("delete_character");
    return true;
}
function mechanicalturk_install()
{
    $mechanicalturk = array('creatureid' => array('name' => 'creatureid', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'creaturename' => array('name' => 'creaturename', 'type' => 'text'), 'creatureweapon' => array('name' => 'creatureweapon', 'type' => 'text'), 'creaturewin' => array('name' => 'creaturewin', 'type' => 'text'), 'creaturelose' => array('name' => 'creaturelose', 'type' => 'text'), 'creaturelevel' => array('name' => 'creaturelevel', 'default' => '0', 'type' => 'int(11) unsigned'), 'forest' => array('name' => 'forest', 'default' => '0', 'type' => 'int(11) unsigned'), 'graveyard' => array('name' => 'graveyard', 'default' => '0', 'type' => 'int(11) unsigned'), 'description' => array('name' => 'description', 'type' => 'text'), 'submittedby' => array('name' => 'submittedby', 'type' => 'text'), 'uid' => array('name' => 'uid', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'creatureid'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('mechanicalturk'), $mechanicalturk, true);
    module_addhook("forest");
    module_addhook("superuser");
    return true;
}
function titans_install()
{
    module_addhook("newday-runonce");
    module_addhook("worldnav");
    $titans = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'creature' => array('name' => 'creature', 'type' => 'text'), 'battlelog' => array('name' => 'battlelog', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('titans'), $titans, true);
    return true;
}
function iitems_hunterslodge_install()
{
    module_addhook("village");
    module_addhook("newday");
    module_addhook("superuser");
    module_addhook("items-returnlinks");
    $purchaselog = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'acctid' => array('name' => 'acctid', 'type' => 'int(11) unsigned'), 'purchased' => array('name' => 'purchased', 'type' => 'text'), 'amount' => array('name' => 'amount', 'type' => 'int(11) unsigned'), 'data' => array('name' => 'data', 'type' => 'text'), 'giftwrap' => array('name' => 'giftwrap', 'type' => 'text'), 'timestamp' => array('name' => 'timestamp', 'type' => 'datetime'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('purchaselog'), $purchaselog, true);
    return true;
}
function tents_install()
{
    $structures = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'owner' => array('name' => 'owner', 'type' => 'int(11) unsigned'), 'type' => array('name' => 'type', 'type' => 'text'), 'location' => array('name' => 'location', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('structures'), $structures, true);
    module_addhook("worldnav");
    module_addhook("newday");
    module_addhook("lodge");
    module_addhook("pointsdesc");
    return true;
}
function translationwizard_install()
{
    module_addhook("superuser");
    module_addhook("header-modules");
    if (is_module_active("translationwizard")) {
        output_notl("`c`b`\$ Module Translationwizard updated`b`c`n`n");
    }
    $wizard = array('tid' => array('name' => 'tid', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'language' => array('name' => 'language', 'type' => 'varchar(10)'), 'uri' => array('name' => 'uri', 'type' => 'varchar(255)'), 'intext' => array('name' => 'intext', 'type' => 'text'), 'outtext' => array('name' => 'outtext', 'type' => 'text'), 'author' => array('name' => 'author', 'type' => 'varchar(50)'), 'version' => array('name' => 'version', 'type' => 'varchar(50)'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'tid'), 'key-one' => array('name' => 'language', 'type' => 'key', 'unique' => '0', 'columns' => 'language,uri'), 'key-two' => array('name' => 'uri', 'type' => 'key', 'unique' => '0', 'columns' => 'uri'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix("temp_translations"), $wizard, true);
    return true;
}
function serverload_install()
{
    $performance = array('numplayers' => array('name' => 'numplayers', 'type' => 'int(11) unsigned'), 'totaltime' => array('name' => 'totaltime', 'type' => 'double unsigned'), 'totalpages' => array('name' => 'totalpages', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'numplayers'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('performance'), $performance, true);
    $performancetime = array('timeslice' => array('name' => 'timeslice', 'type' => 'int(11) unsigned'), 'totaltime' => array('name' => 'totaltime', 'type' => 'double unsigned'), 'totalpages' => array('name' => 'totalpages', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'timeslice'));
    synctable(db_prefix('performancetime'), $performancetime, true);
    module_addhook("player-login");
    module_addhook("player-logout");
    module_addhook("newday-runonce");
    return true;
}
function scrapbots_install()
{
    $scrapbots = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'owner' => array('name' => 'owner', 'type' => 'int(11) unsigned'), 'name' => array('name' => 'name', 'type' => 'text'), 'activated' => array('name' => 'activated', 'type' => 'int(11) unsigned'), 'hitpoints' => array('name' => 'hitpoints', 'type' => 'int(11) unsigned'), 'brains' => array('name' => 'brains', 'type' => 'int(11) unsigned'), 'brawn' => array('name' => 'brawn', 'type' => 'int(11) unsigned'), 'briskness' => array('name' => 'briskness', 'type' => 'int(11) unsigned'), 'junglefighter' => array('name' => 'junglefighter', 'type' => 'int(11) unsigned'), 'retreathp' => array('name' => 'retreathp', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('scrapbots'), $scrapbots, true);
    module_addhook("village");
    module_addhook("newday");
    require_once "modules/staminasystem/lib/lib.php";
    install_action("Scavenging for Scrap", array("maxcost" => 10000, "mincost" => 2500, "firstlvlexp" => 1500, "expincrement" => 1.1, "costreduction" => 75, "class" => "ScrapBots"));
    install_action("Metalworking", array("maxcost" => 10000, "mincost" => 3000, "firstlvlexp" => 1500, "expincrement" => 1.1, "costreduction" => 60, "class" => "ScrapBots"));
    install_action("Soldering", array("maxcost" => 10000, "mincost" => 3000, "firstlvlexp" => 1500, "expincrement" => 1.1, "costreduction" => 60, "class" => "ScrapBots"));
    install_action("Programming", array("maxcost" => 10000, "mincost" => 3000, "firstlvlexp" => 1500, "expincrement" => 1.1, "costreduction" => 60, "class" => "ScrapBots"));
    return true;
}
function improbablehousing_install()
{
    module_addhook("worldnav");
    module_addhook("village");
    module_addhook("newday");
    module_addhook("stamina-newday");
    require_once "lib/tabledescriptor.php";
    $housing = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'ownedby' => array('name' => 'ownedby', 'type' => 'int(11) unsigned'), 'location' => array('name' => 'location', 'type' => 'text'), 'data' => array('name' => 'data', 'type' => 'mediumtext'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    synctable(db_prefix('improbabledwellings'), $housing, true);
    $buildings = array('hid' => array('name' => 'hid', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'ownedby' => array('name' => 'ownedby', 'type' => 'int(11) unsigned'), 'location' => array('name' => 'location', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'hid'));
    $building_prefs = array('hid' => array('name' => 'hid', 'type' => 'int(11) unsigned'), 'pref' => array('name' => 'pref', 'type' => 'varchar(50)'), 'value' => array('name' => 'value', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'hid,pref'));
    $rooms = array('hid' => array('name' => 'hid', 'type' => 'int(11) unsigned'), 'rid' => array('name' => 'rid', 'type' => 'int(11) unsigned'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'hid,rid'));
    $room_prefs = array('hid' => array('name' => 'hid', 'type' => 'int(11) unsigned'), 'rid' => array('name' => 'rid', 'type' => 'int(11) unsigned'), 'pref' => array('name' => 'pref', 'type' => 'varchar(50)'), 'value' => array('name' => 'value', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'hid,rid,pref'));
    synctable(db_prefix('buildings'), $buildings, true);
    synctable(db_prefix('building_prefs'), $building_prefs, true);
    synctable(db_prefix('rooms'), $rooms, true);
    synctable(db_prefix('room_prefs'), $room_prefs, true);
    // 'module_userprefs'=>array(
    // 'modulename'=>array(
    // 'name'=>'modulename', 'type'=>'varchar(50)'
    // ),
    // 'setting'=>array(
    // 'name'=>'setting', 'type'=>'varchar(50)'
    // ),
    // 'userid'=>array(
    // 'name'=>'userid', 'type'=>'int(11) unsigned', 'default'=>'0'
    // ),
    // 'value'=>array(
    // 'name'=>'value', 'type'=>'text', 'null'=>'1'
    // ),
    // 'key-PRIMARY'=>array(
    // 'name'=>'PRIMARY',
    // 'type'=>'primary key',
    // 'unique'=>'1',
    // 'columns'=>'modulename,setting,userid'
    // ),
    // 'key-modulename'=>array(
    // 'name'=>'modulename', 'type'=>'key', 'columns'=>'modulename,userid'
    // ),
    // 'key-userid'=>array( // Speed up char deletion, takes a lot of space, though
    // 'name'=>'userid', 'type'=>'key', 'columns'=>'userid'
    // ),
    // ),
    //synctable(db_prefix('improbabledwellings'), $housing, true);
    require_once "modules/staminasystem/lib/lib.php";
    install_action("Masonry", array("maxcost" => 50000, "mincost" => 20000, "firstlvlexp" => 500, "expincrement" => 1.05, "costreduction" => 300, "class" => "Building"));
    install_action("Carpentry", array("maxcost" => 50000, "mincost" => 20000, "firstlvlexp" => 500, "expincrement" => 1.05, "costreduction" => 300, "class" => "Building"));
    install_action("Decorating", array("maxcost" => 50000, "mincost" => 20000, "firstlvlexp" => 500, "expincrement" => 1.05, "costreduction" => 300, "class" => "Building"));
    return true;
}
function iitems_install()
{
    $items = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'localname' => array('localname' => 'name', 'type' => 'text'), 'data' => array('name' => 'data', 'type' => 'text'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'));
    require_once "lib/tabledescriptor.php";
    synctable(db_prefix('iitems'), $items, true);
    module_addhook("superuser");
    module_addhook("village");
    module_addhook("forest");
    module_addhook("worldnav");
    module_addhook("fightnav-specialties");
    module_addhook("apply-specialties");
    module_addhook("dragonkill");
    module_addhook("newday");
    return true;
}
Exemple #14
0
function reloadtable($table)
{
    //ccm-rle 9-30-09 this is where it is only synching to LANE03, using LANE02 now, will add to database, shouldn't be hardcoded but the previous query might not of been working
    $aLane = array(LANE01, LANE02, LANE03, LANE04);
    //why are these stored in a session?
    //	$_SESSION["mUser"] = "******";
    //	$_SESSION["laneUser"] = "******";
    $server = "localhost";
    $opDB = "is4c_op";
    $serveruser = $_SESSION["mUser"];
    $serverpass = $_SESSION["mPass"];
    $laneuser = $_SESSION["laneUser"];
    $lanepass = $_SESSION["lanePass"];
    $file = "/pos/is4c/download/" . $table . ".out";
    $dump = "select * into outfile '" . $file . "' from " . $table;
    $load = "load data infile '" . $file . "' into table is4c_op." . $table;
    $is4c_op_truncate = "truncate is4c_op." . $table;
    $opdata_truncate = "truncate opdata." . $table;
    $opdata_insert = "insert into opdata. " . $table . " select * from is4c_op." . $table;
    echo "<font color='#004080' face=helvetica><b>" . $table . "</b></font>";
    echo "<p>";
    $continue = 0;
    /* establish connection to server */
    if ($s_conn = mysql_connect($server, $serveruser, $serverpass)) {
        $continue = 1;
    } else {
        echo "<p><font color='#800000' face=helvetica size=-1>Failed to connect to server</font>";
    }
    if ($continue == 1) {
        $continue = 0;
        if (mysql_select_db("is4c_op", $s_conn)) {
            $continue = 1;
        } else {
            echo "<p><font color='#800000' face=helvetica size=-1>Failed to connect to server database</font>";
        }
    }
    if ($continue == 1) {
        $continue = 0;
        $result = mysql_query("select count(*) from " . $table, $s_conn);
        $row = mysql_fetch_array($result);
        $server_num_rows = $row[0];
        // echo "<p><font color='#004080' face=helvetica size=-1>There are ".$server_num_rows." record(s) on server database</font>";
        if ($server_num_rows > 1) {
            $continue = 1;
        } else {
            echo "<p><font color='#800000' face=helvetica size=-1>There are only " . $server_num_rows . " records on the server.<br>No way</font>";
        }
    }
    /*
    if ($continue == 1) {
    
    	$continue = 0;
    	if (file_exists($file)) exec("rm ".$file);
    	if (mysql_query($dump, $s_conn)) $continue = 1;
    	else echo "<p><font color='#800000' face=helvetica size=-1>Failed to download new data from server</font>";
    
    }
    
    
    if ($continue == 1) {
    
    	$continue = 0;
    	if (file_exists($file)) $continue = 1;
    	else echo "<p><font color='#800000' face=helvetica size=-1>Failed to retrieve new data from server</font>";
    
    } 
    */
    // synchronize lanes
    if ($continue == 1) {
        //	$continue = 0;
        //	echo "<p><font color='#004080' face=helvetica size=-1>".$server_num_rows." records downloaded from server</font>";
        //	echo "<p>";
        // ccm-rle 9-30-09 this is where pat hardcoded the starting point as 3 for lane 3. changed it to 2
        $i = 1;
        foreach ($aLane as $lane) {
            if ($lane && strlen($lane) > 0) {
                $lane_num = "lane " . $i;
                $i++;
                $lane_continue = 0;
                if ($lane_conn = mysql_connect($lane, $laneuser, $lanepass)) {
                    $lane_continue = 1;
                } else {
                    echo "<br><font color='#800000' face=helvetica size=-1>Unable to connect to " . $lane_num . "</font>";
                }
                //select lane database
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    if (mysql_select_db("opdata", $lane_conn)) {
                        $lane_continue = 1;
                    } else {
                        echo "<br><font color='#800000' face=helvetica size=-1>Unable to select database on " . $lane_num . "</font>";
                    }
                }
                //truncate lane database
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    //mysql_query("create table is4c_op." . $table . "_temp as select * from is4c_op." . $table .", $lane_conn);
                    mysql_query($is4c_op_truncate, $lane_conn);
                    if (synctable($table, $serveruser, $serverpass, $laneuser, $lanepass, $opDB, $lane) == 1) {
                        $result = mysql_query("select count(*) from is4c_op." . $table, $lane_conn);
                        $row = mysql_fetch_array($result);
                        $lane_num_rows = $row[0];
                        if ($lane_num_rows == $server_num_rows) {
                            $lane_continue = 1;
                        } else {
                            echo "<br><font color='#800000' face=helvetica size=-1>" . $lane_num . ": Number of records do not match. Synchronization refused</font>";
                        }
                    } else {
                        echo "<br><font color='#800000' face=helvetica size=-1>Unable to load new data onto " . $lane_num . "</font>";
                    }
                }
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    if (mysql_query($opdata_truncate, $lane_conn)) {
                        if (mysql_query($opdata_insert, $lane_conn)) {
                            $qresult = mysql_query("select * from " . $table, $lane_conn);
                            $lane_num_rows = mysql_num_rows($qresult);
                            echo "<br><font color='#004080' face=helvetica size=-1>" . $lane_num . ": " . $lane_num_rows . " records successfully synchronized";
                        } else {
                            echo "<br><font color='#800000' face=helvetica size=-1>Unable to synchronize " . $lane_num . "</font>";
                        }
                    }
                }
            }
        }
    }
    $time = strftime("%m-%d-%y %I:%M %p", time());
    echo "<p> <p><font color='#004080' face=helvetica size=-1>last run: " . $time . "</font>";
}
		'logrooms'=>array('name'=>'logrooms', 'type'=>'int unsigned', 'default'=>'0'),
		'logmeals'=>array('name'=>'logmeals', 'type'=>'int unsigned', 'default'=>'0'),
		'logdrinks'=>array('name'=>'logdrinks', 'type'=>'int unsigned', 'default'=>'0'),
		'statroomsprofit'=>array('name'=>'statroomsprofit', 'type'=>'int unsigned', 'default'=>'0'),
		'statmealsprofit'=>array('name'=>'statmealsprofit', 'type'=>'int unsigned', 'default'=>'0'),
		'statdrinksprofit'=>array('name'=>'statdrinksprofit', 'type'=>'int unsigned', 'default'=>'0'),
		'statrooms'=>array('name'=>'statrooms', 'type'=>'int unsigned', 'default'=>'0'),
		'statmeals'=>array('name'=>'statmeals', 'type'=>'int unsigned', 'default'=>'0'),
		'statdrinks'=>array('name'=>'statdrinks', 'type'=>'int unsigned', 'default'=>'0'),
		'statmealsbought'=>array('name'=>'statmealsbought', 'type'=>'int unsigned', 'default'=>'0'),
		'statticks'=>array('name'=>'statticks', 'type'=>'int unsigned', 'default'=>'0'),
		'key-PRIMARY'=>array('name'=>'PRIMARY', 'type'=>'primary key',	'unique'=>'1', 'columns'=>'dwid'),
		'index-dwid'=>array('name'=>'dwid', 'type'=>'index', 'columns'=>'dwid')
	);
	
	synctable(db_prefix('dwinns'), $dwinns, true);
	
	module_addhook("village");
	module_addhook("newday");
	module_addhook("newday-runonce");
	module_addhook_priority("dwellings",100);
	module_addhook("dwellings-inside");
	module_addhook("dwellings-manage");
	module_addhook("dwellings-list-type");
	module_addhook("dwellings-list-interact");
	module_addhook("dragonkill");
	module_addhook("dwellings-addsleepers");
	
	if (!is_module_active('dwinns')){
		$sql="SELECT module FROM ".db_prefix("dwellingtypes")." WHERE module='dwinns'";
		$res=db_query($sql);
Exemple #16
0
function reloadtable($table)
{
    // require_once('../define.conf');
    $aLane = array(LANE01, LANE02);
    // $_SESSION["mUser"] = "******";
    // $_SESSION["laneUser"] = "******";
    //
    // $server = "localhost";
    // $opDB = "is4c_op";
    // $serveruser = $_SESSION["mUser"];
    // $serverpass = $_SESSION["mPass"];
    //
    // $laneuser = $_SESSION["laneUser"];
    // $lanepass = $_SESSION["lanePass"];
    // $file = "/pos/is4c/download/".$table.".out";
    // 	$dump = "select * into outfile '".$file."' from ".$table;
    // 	$load = "load data infile '".$file."' into table is4c_op.".$table;
    $is4c_op_truncate = "TRUNCATE " . DB_NAME . "." . $table;
    $opdata_truncate = "TRUNCATE " . LANE_DB . "." . $table;
    $opdata_insert = "INSERT INTO " . LANE_DB . "." . $table . " SELECT * FROM " . DB_NAME . "." . $table;
    echo "<font color='#004080' face=helvetica><b>" . $table . "</b></font>";
    echo "<p>";
    $continue = 0;
    /* establish connection to server */
    if ($s_conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) {
        // if ($dbc) {
        $continue = 1;
    } else {
        echo "<p><font color='#800000' face=helvetica size=-1>Failed to connect to server<br />" . mysql_error() . "</font>";
    }
    if ($continue == 1) {
        $continue = 0;
        if (mysql_select_db(DB_NAME, $s_conn)) {
            $continue = 1;
        } else {
            echo "<p><font color='#800000' face=helvetica size=-1>Failed to connect to server database</font>";
        }
    }
    if ($continue == 1) {
        $continue = 0;
        $result = mysql_query("SELECT COUNT(*) FROM " . $table, $s_conn);
        $row = mysql_fetch_array($result);
        $server_num_rows = $row[0];
        // echo "<p><font color='#004080' face=helvetica size=-1>There are ".$server_num_rows." record(s) on server database</font>";
        if ($server_num_rows > 5) {
            $continue = 1;
        } else {
            echo "<p><font color='#800000' face=helvetica size=-1>There are only " . $server_num_rows . " records on the server.<br>No way</font>";
        }
    }
    /*
    	if ($continue == 1) {
    
    		$continue = 0;
    		if (file_exists($file)) exec("rm ".$file);
    		if (mysql_query($dump, $s_conn)) $continue = 1;
    		else echo "<p><font color='#800000' face=helvetica size=-1>Failed to download new data from server</font>";
    
    	}
    
    
    	if ($continue == 1) {
    
    		$continue = 0;
    		if (file_exists($file)) $continue = 1;
    		else echo "<p><font color='#800000' face=helvetica size=-1>Failed to retrieve new data from server</font>";
    
    	} 
    */
    // synchronize lanes
    if ($continue == 1) {
        //	$continue = 0;
        //	echo "<p><font color='#004080' face=helvetica size=-1>".$server_num_rows." records downloaded from server</font>";
        //	echo "<p>";
        $i = 1;
        foreach ($aLane as $lane) {
            if ($lane && strlen($lane) > 0) {
                $lane_num = "lane " . $i;
                $i++;
                $lane_continue = 0;
                // print "-h " . $lane . " -u " . LANE_DB_USER . " -p " . LANE_DB_PASS;
                if ($lane_conn = mysql_connect($lane, LANE_DB_USER, LANE_DB_PASS)) {
                    $lane_continue = 1;
                } else {
                    echo "<br><font color='#800000' face=helvetica size=-1>Unable to connect to " . $lane_num . "</font>";
                }
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    if (mysql_select_db(LANE_DB, $lane_conn)) {
                        $lane_continue = 1;
                    } else {
                        echo "<br><font color='#800000' face=helvetica size=-1>Unable to select database on " . $lane_num . "</font>";
                    }
                }
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    mysql_query($is4c_op_truncate, $lane_conn);
                    if (synctable($table, $lane) == 1) {
                        $result = mysql_query("select count(*) from " . DB_NAME . "." . $table, $lane_conn);
                        $row = mysql_fetch_array($result);
                        $lane_num_rows = $row[0];
                        if ($lane_num_rows == $server_num_rows) {
                            $lane_continue = 1;
                        } else {
                            echo "<br><font color='#800000' face=helvetica size=-1>" . $lane_num . ": Number of records do not match. Synchronization refused</font>";
                        }
                    } else {
                        echo "<br><font color='#800000' face=helvetica size=-1>Unable to load new data onto " . $lane_num . "</font>";
                    }
                }
                if ($lane_continue == 1) {
                    $lane_continue = 0;
                    if (mysql_query($opdata_truncate, $lane_conn)) {
                        if (mysql_query($opdata_insert, $lane_conn)) {
                            $qresult = mysql_query("select * from " . $table, $lane_conn);
                            $lane_num_rows = mysql_num_rows($qresult);
                            echo "<br><font color='#004080' face=helvetica size=-1>" . $lane_num . ": " . $lane_num_rows . " records successfully synchronized";
                        } else {
                            echo "<br><font color='#800000' face=helvetica size=-1>Unable to synchronize " . $lane_num . "</font>";
                        }
                    }
                }
            }
        }
    }
    $time = strftime("%m-%d-%y %I:%M %p", time());
    echo "<p> <p><font color='#004080' face=helvetica size=-1>last run: " . $time . "</font>";
}
<?php

global $session;
$equipmentbuffs = db_prefix("magicitembuffs");
$equipment = db_prefix("magicitems");
$new_items = array('buffid' => array('name' => 'buffid', 'type' => 'tinyint unsigned', 'null' => '0'));
$buff_table = array('buffid' => array('name' => 'buffid', 'type' => 'tinyint unsigned', 'null' => '0', 'extra' => 'auto_increment'), 'buffname' => array('name' => 'buffname', 'type' => 'varchar(255)', 'null' => '0'), 'itembuff' => array('name' => 'itembuff', 'type' => 'text', 'null' => '1'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'buffid'));
require_once "lib/tabledescriptor.php";
synctable($equipment, $new_items, true);
synctable($equipmentbuffs, $buff_table, true);
module_addhook("mysticalshop-editor");
module_addhook("mysticalshop-buy");
module_addhook("mysticalshop-preview");
module_addhook("mysticalshop-sell-after");
module_addhook("newday");
Exemple #18
0
<?php

/*******************************************************************************

    Copyright 2007 People's Food Co-op, Portland, Oregon.

    This file is part of Fannie.

    IS4C is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    IS4C is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    in the file license.txt along with IS4C; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*********************************************************************************/
include "reload.php";
if (synctable("products") == 1) {
    echo "Yay!  It worked";
} else {
    echo "Nope.  Broken.";
}
<?php

$magic_items = array('id' => array('name' => 'id', 'type' => 'int(11) unsigned', 'extra' => 'auto_increment'), 'category' => array('name' => 'category', 'type' => 'int(10) unsigned', 'default' => '0'), 'name' => array('name' => 'name', 'type' => 'varchar(50)', 'default' => 'None'), 'description' => array('name' => 'description', 'type' => 'text'), 'gold' => array('name' => 'gold', 'default' => '0', 'type' => 'int(11) unsigned'), 'gems' => array('name' => 'gems', 'default' => '0', 'type' => 'int(11) unsigned'), 'dk' => array('name' => 'dk', 'type' => 'int(11)', 'default' => '0'), 'attack' => array('name' => 'attack', 'type' => 'varchar(11)', 'default' => '0'), 'defense' => array('name' => 'defense', 'type' => 'varchar(11)', 'default' => '0'), 'charm' => array('name' => 'charm', 'type' => 'varchar(11)', 'default' => '0'), 'hitpoints' => array('name' => 'hitpoints', 'type' => 'varchar(11)', 'default' => '0'), 'turns' => array('name' => 'turns', 'type' => 'varchar(11)', 'default' => '0'), 'favor' => array('name' => 'favor', 'type' => 'varchar(11)', 'default' => '0'), 'bigdesc' => array('name' => 'bigdesc', 'type' => 'text'), 'align' => array('name' => 'align', 'type' => 'varchar(11)', 'default' => '0'), 'odor' => array('name' => 'odor', 'type' => 'varchar(11)', 'default' => '0'), 'hunger' => array('name' => 'hunger', 'type' => 'varchar(11)', 'default' => '0'), 'rare' => array('name' => 'rare', 'type' => 'tinyint(3)', 'default' => '0'), 'rarenum' => array('name' => 'rarenum', 'type' => 'int(11)', 'default' => '0'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'id'), 'index-category' => array('name' => 'category', 'type' => 'index', 'columns' => 'category'));
require_once "lib/tabledescriptor.php";
synctable(db_prefix('magicitems'), $magic_items, true);
if (getsetting('usedatacache', false)) {
    invalidatedatacache('modules-mysticalshop-enter');
    invalidatedatacache('modules-mysticalshop-viewgoods');
    invalidatedatacache('module-mysticalshop-selectall-ordercat');
    require_once './modules/mysticalshop/libcoredup.php';
    mysticalshop_massinvalidate('modules-mysticalshop-');
}
module_addhook("superuser");
module_addhook("village");
module_addhook("dragonkill");
module_addhook("newday");
module_addhook("lodge");
module_addhook("pointsdesc");
module_addhook("charstats");
module_addhook("changesetting");
module_addhook("training-victory");
module_addhook("bioinfo");
module_addhook("validateprefs");
                    if (activate_module($modulename)) {
                        output("`@OK!`0`n");
                    } else {
                        output("`\$Failed!`0`n");
                    }
                    break;
                case "deactivate":
                    output("`3Deactivating `#{$modulename}`3: ");
                    if (deactivate_module($modulename)) {
                        output("`@OK!`0`n");
                    } else {
                        output("`\$Failed!`0`n");
                    }
                    break;
                case "donothing":
                    break;
            }
        }
        $session['moduleoperations'][$modulename] = "donothing";
    }
    rawoutput("</div>");
}
output("`n`2Finally, I'll clean up old data.`n");
rawoutput("<div style='width: 100%; height: 150px; max-height: 150px; overflow: auto;'>");
reset($descriptors);
while (list($tablename, $descriptor) = each($descriptors)) {
    output("`3Cleaning up `#{$tablename}`3...`n");
    synctable($tablename, $descriptor);
}
rawoutput("</div>");
output("`n`n`^You're ready for the next step.");
    if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
        output_notl("`4Updating dwellings Module: dwitems.`n");
    }
}
/*
 * TYPE
 * 0 = charm
 * 1 = gold
 * 2 = gem
 * 3 = hp
 * 4 = maxhp
 * 5 = favor
 * 6 = turn
 * 7 = script
 */
$dwitems = array('itemid' => array('name' => 'itemid', 'type' => 'int unsigned'), 'name' => array('name' => 'name', 'type' => 'varchar(50)'), 'type' => array('name' => 'type', 'type' => 'int unsigned'), 'amount' => array('name' => 'amount', 'type' => 'int'), 'chance' => array('name' => 'chance', 'type' => 'int unsigned'), 'goldcost' => array('name' => 'goldcost', 'type' => 'int unsigned'), 'gemcost' => array('name' => 'gemcost', 'type' => 'int unsigned'), 'mindk' => array('name' => 'mindk', 'type' => 'varchar(50)'), 'newdaytext' => array('name' => 'newdaytext', 'type' => 'varchar(200)', 'null' => '1'), 'dwellingtext' => array('name' => 'dwellingtext', 'type' => 'varchar(200)', 'null' => '1'), 'dwellingtextplural' => array('name' => 'dwellingtextplural', 'type' => 'varchar(200)', 'null' => '1'), 'key-PRIMARY' => array('name' => 'PRIMARY', 'type' => 'primary key', 'unique' => '1', 'columns' => 'itemID'));
$dwellingsitems = array('itemid' => array('name' => 'itemid', 'type' => 'int unsigned'), 'dwid' => array('name' => 'dwid', 'type' => 'int unsigned'), 'quantity' => array('quantity' => 'dwid', 'type' => 'int unsigned'));
synctable(db_prefix('dwitems'), $dwitems, true);
synctable(db_prefix('dwellingsitems'), $dwellingsitems, true);
$sql = "SELECT itemid FROM " . db_prefix("dwitems");
$result = db_query($sql);
if (db_num_rows($result) == 0) {
    $sql = "INSERT INTO " . db_prefix("dwitems") . " VALUES (0, 'ming vase', 0, 1, 10, 200, 2, 1, '`3Violet comes for a visit and sees your ming vase. She is impressed by your taste in foreign art.`n', '`2A ming vase is standing in the corner.`0`n', '`2Nicely arranged across the room are %s ming vases.`0`n')";
    db_query($sql);
    $sql = "INSERT INTO " . db_prefix("dwitems") . " VALUES (1, 'pillow', 3, 5, 10, 50, 0, 0, '`4Your pillow felt very fluffy last night. You feel well rested.`n', '`2On the bed lies a small pillow.`0`n', '`2The bed is cushioned with %s pillows`0`n')";
    db_query($sql);
}
module_addhook("village");
module_addhook_priority("newday", 10);
module_addhook("dwellings-inside");
module_addhook("superuser");