Example #1
0
 * update all code-version-dependent data on a developer system
 */
$rootpath = $opt['rootpath'] = __DIR__ . '/../htdocs/';
chdir($rootpath);
require_once 'lib2/cli.inc.php';
echo "updating composer dependencies\n";
system('composer install --ignore-platform-reqs');
echo "applying sql deltas\n";
require 'dbsv-update.php';
echo "importing data.sql\n";
system('cat ' . $rootpath . '../sql/static-data/data.sql |' . ' mysql -h' . $opt['db']['servername'] . ' -u' . $opt['db']['username'] . ' --password='******'db']['password'] . ' ' . $opt['db']['placeholder']['db']);
echo "importing triggers\n";
chdir($rootpath . '../sql/stored-proc');
system('php maintain.php');
// We do *two* tests for OKAPI presence to get some robustness agains internal OKAPI changes.
//
// This should be replaced by a facade function call, but current OKAPI implementation
// does not work well when called from the command line, due to exception handling problems
// (see http://code.google.com/p/opencaching-api/issues/detail?id=243).
$okapi_vars = sql_table_exists('okapi_vars');
$okapi_syncbase = sql_field_exists('caches', 'okapi_syncbase');
if ($okapi_vars != $okapi_syncbase) {
    echo "!! unknown OKAPI configuration; either dbupdate.php needs an update or your database configuration is wrong\n";
} elseif ($okapi_vars) {
    echo "updating OKAPI database\n";
    chdir($rootpath . '../bin');
    system('php okapi-update.php | grep -i -e mutation');
}
echo "resetting webcache:\n";
chdir($rootpath . '../bin');
system('php clear-webcache.php');
Example #2
0
function dbv_150()
{
    if (!sql_table_exists('waypoint_reports')) {
        sql("CREATE TABLE `waypoint_reports` (\n                `report_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n                `date_reported` DATETIME NOT NULL,\n                `wp_oc` VARCHAR(7) NOT NULL,\n                `wp_external` VARCHAR(8) NOT NULL,\n                `source` VARCHAR(64) NOT NULL,\n                `gcwp_processed` TINYINT(1) NOT NULL DEFAULT '0',\n                PRIMARY KEY  (`report_id`),\n                KEY `gcwp_processed` (`gcwp_processed`,`date_reported`)\n             ) ENGINE=MyISAM");
    }
}
while ($r = sql_fetch_assoc($rs)) {
    echo '.';
    sql("DELETE FROM `caches` WHERE `cache_id`='&1'", $r['cache_id']);
}
echo "\n";
mysql_free_result($rs);
echo "deleting inactive users\n";
$rs = sql("SELECT `user_id`\n     FROM `user`\n     WHERE `user_id` NOT IN\n        (SELECT `user_id` FROM `caches`\n         UNION\n         SELECT `user_id` FROM `cache_logs`)");
while ($r = sql_fetch_assoc($rs)) {
    echo ".";
    sql("DELETE FROM `user` WHERE `user_id`='&1'", $r['user_id']);
}
echo "\n";
mysql_free_result($rs);
echo "clearing OKAPI data\n";
if (sql_table_exists('okapi_vars')) {
    echo "clearing OKAPI data\n";
    sql('TRUNCATE `okapi_authorizations`');
    sql('TRUNCATE `okapi_cache_logs`');
    sql('TRUNCATE `okapi_cache_reads`');
    sql('TRUNCATE `okapi_consumers`');
    sql('TRUNCATE `okapi_nonces`');
    sql('TRUNCATE `okapi_search_results`');
    sql('TRUNCATE `okapi_search_sets`');
    sql('TRUNCATE `okapi_stats_hourly`');
    sql('TRUNCATE `okapi_stats_monthly`');
    sql('TRUNCATE `okapi_stats_temp`');
    sql('TRUNCATE `okapi_tile_caches`');
    sql('TRUNCATE `okapi_tile_status`');
    sql('TRUNCATE `okapi_tokens`');
}
Example #4
0
function dbv_150()
{
    if (!sql_table_exists('waypoint_reports')) {
        sql("\n\t\t\t\tCREATE TABLE `waypoint_reports` (\n\t\t\t\t\t`report_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t\t\t`date_reported` datetime NOT NULL,\n\t\t\t\t\t`wp_oc` varchar(7) NOT NULL,\n\t\t\t\t\t`wp_external` varchar(8) NOT NULL,\n\t\t\t\t\t`source` varchar(64) NOT NULL,\n\t\t\t\t\t`gcwp_processed` tinyint(1) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY  (`report_id`),\n\t\t\t\t\tKEY `gcwp_processed` (`gcwp_processed`,`date_reported`)\n\t\t\t\t) ENGINE=MyISAM");
    }
}
Example #5
0
function dbv_136()
{
    if (!sql_table_exists('towns')) {
        sql("\n\t\t\t\tCREATE TABLE `towns` (\n\t\t\t\t  `country` char(2) NOT NULL,\n\t\t\t\t  `name` varchar(40) NOT NULL,\n\t\t\t\t  `trans_id` int(10) unsigned NOT NULL,\n\t\t\t\t  `coord_lat` double NOT NULL,\n\t\t\t\t  `coord_long` double NOT NULL,\n\t\t\t\t  `maplist` tinyint(1) NOT NULL default '0',\n\t\t\t\t  KEY `country` (`country`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
    }
}
Example #6
0
function dbv_124()
{
    if (!sql_table_exists('stat_cache_lists')) {
        sql("\n\t\t\t\tCREATE TABLE `stat_cache_lists` (\n\t\t\t\t  `cache_list_id` int(10) NOT NULL,\n\t\t\t\t  `entries` int(6) NOT NULL default '0' COMMENT 'via trigger in cache_list_items',\n\t\t\t\t  `watchers` int(6) NOT NULL default '0' COMMENT 'via trigger in cache_list_watches',\n\t\t\t\t  PRIMARY KEY (`cache_list_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8\n\t\t\t\tSELECT `id` `cache_list_id`, `entries`, `watchers` FROM `cache_lists`");
    }
    if (sql_field_exists('cache_lists', 'entries')) {
        sql("ALTER TABLE `cache_lists` DROP COLUMN `entries`");
    }
    if (sql_field_exists('cache_lists', 'watchers')) {
        sql("ALTER TABLE `cache_lists` DROP COLUMN `watchers`");
    }
    if (!sql_field_exists('cache_lists', 'description')) {
        sql("ALTER TABLE `cache_lists` ADD COLUMN `description` mediumtext NOT NULL");
    }
    if (!sql_field_exists('cache_lists', 'desc_htmledit')) {
        sql("ALTER TABLE `cache_lists` ADD COLUMN `desc_htmledit` tinyint(1) unsigned NOT NULL default '1'");
    }
    update_triggers();
    // runs maintain-124.inc.php
}