Exemplo n.º 1
0
 /**
  * Performs all "ExpensiveCheck" methods. Note that this is usually
  * invoked in the Configuration check screen and therefore any
  * errors set here are "non-lethal", i.e. the application still works
  * although certain features may not function properly.
  */
 public static function performExpensive()
 {
     self::$opa_error_messages = array();
     self::$opo_db = new Db();
     self::$opo_config = ConfigurationCheck::$opo_db->getConfig();
     /* execute checks */
     $vo_reflection = new ReflectionClass("ConfigurationCheck");
     $va_methods = $vo_reflection->getMethods();
     foreach ($va_methods as $vo_method) {
         if (strpos($vo_method->name, "ExpensiveCheck") !== false) {
             if (!$vo_method->invoke("ConfigurationCheck")) {
                 // true means keep on doing checks; false means stop performing checks
                 return;
             }
         }
     }
 }
Exemplo n.º 2
0
<div id='box'>
	<div id="logo"><img src="<?php 
print $vs_url_path;
?>
/graphics/ca_logo.png"/></div><!-- end logo -->
	<div id="content">
	<H1>
		<?php 
_p('Version %1 installer (XML)', constant('__CollectiveAccess__'));
?>
	</H1>
<?php 
// Check for configuration issues
ConfigurationCheck::performInstall();
if (ConfigurationCheck::foundErrors()) {
    ConfigurationCheck::renderInstallErrorsAsHTMLOutput();
} else {
    ?>
	
	<p>
		<?php 
    _p("This installer will have your installation of CollectiveAccess ready to use in just a few minutes. \n\t\tBefore you run the installer make sure the settings in your <i>setup.php</i> file are correct. \n\t\tThe installer will test your database connection, install the database schema and load default values into the newly established database. \n\t\tIt will also establish an administrator's login for you to use to access your new system.");
    ?>
	</p>
	<div id="installForm">
		<form action='index.php' name='page1form' id='page1form'>
			<div class='formItem'>
<?php 
    if (sizeof($va_errors)) {
        print "<div class='contentError'><img src='{$vs_url_path}/graphics/warning.gif'/> " . _t('Please enter a valid email address') . "</div>\n";
    }
Exemplo n.º 3
0
 /**
  * Update database schema
  */
 public static function update_database_schema($po_opts = null)
 {
     require_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php";
     $o_config_check = new ConfigurationCheck();
     if (($vn_current_revision = ConfigurationCheck::getSchemaVersion()) < __CollectiveAccess_Schema_Rev__) {
         CLIUtils::addMessage(_t("Are you sure you want to update your CollectiveAccess database from revision %1 to %2?\nNOTE: you should backup your database before applying updates!\n\nType 'y' to proceed or 'N' to cancel, then hit return ", $vn_current_revision, __CollectiveAccess_Schema_Rev__));
         flush();
         ob_flush();
         $confirmation = trim(fgets(STDIN));
         if ($confirmation !== 'y') {
             // The user did not say 'y'.
             return false;
         }
         $va_messages = ConfigurationCheck::performDatabaseSchemaUpdate();
         print CLIProgressBar::start(sizeof($va_messages), _t('Updating database'));
         foreach ($va_messages as $vs_message) {
             print CLIProgressBar::next(1, $vs_message);
         }
         print CLIProgressBar::finish();
     } else {
         print CLIProgressBar::finish();
         CLIUtils::addMessage(_t("Database already at revision %1. No update is required.", __CollectiveAccess_Schema_Rev__));
     }
     return true;
 }
Exemplo n.º 4
0
require './setup.php';
define("__CA_BASE_MEMORY_USAGE__", memory_get_usage(true));
// connect to database
$o_db = new Db(null, null, false);
if (!$o_db->connected()) {
    $opa_error_messages = array("Could not connect to database. Check your database configuration in <em>setup.php</em>.");
    require_once __CA_BASE_DIR__ . "/themes/default/views/system/configuration_error_html.php";
    exit;
}
//
// do a sanity check on application and server configuration before servicing a request
//
require_once __CA_APP_DIR__ . '/lib/pawtucket/ConfigurationCheck.php';
ConfigurationCheck::performQuick();
if (ConfigurationCheck::foundErrors()) {
    ConfigurationCheck::renderErrorsAsHTMLOutput();
    exit;
}
$app = AppController::getInstance();
$g_request = $app->getRequest();
$resp = $app->getResponse();
// TODO: move this into a library so $_, $g_ui_locale_id and $g_ui_locale gets set up automatically
require_once __CA_APP_DIR__ . "/helpers/initializeLocale.php";
$va_ui_locales = $g_request->config->getList('ui_locales');
if ($vs_lang = $g_request->getParameter('lang', pString)) {
    if (in_array($vs_lang, $va_ui_locales)) {
        $g_request->session->setVar('lang', $vs_lang);
    }
}
if (!($g_ui_locale = $g_request->session->getVar('lang'))) {
    $g_ui_locale = $va_ui_locales[0];
Exemplo n.º 5
0
 /**
  *
  */
 public static function do_configuration_check($po_opts = null)
 {
     include_once __CA_LIB_DIR__ . "/core/Search/SearchEngine.php";
     include_once __CA_LIB_DIR__ . "/core/Media.php";
     include_once __CA_LIB_DIR__ . "/ca/ApplicationPluginManager.php";
     include_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php";
     require_once __CA_LIB_DIR__ . "/core/Configuration.php";
     // Media
     $t_media = new Media();
     $va_plugin_names = $t_media->getPluginNames();
     CLIUtils::addMessage(_t("Checking media processing plugins..."), array('color' => 'bold_blue'));
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_media->checkPluginStatus($vs_plugin_name)) {
             CLIUtils::addMessage("\t" . _t("Found %1", $vs_plugin_name));
         }
     }
     CLIUtils::addMessage("\n");
     // Application plugins
     CLIUtils::addMessage(_t("Checking application plugins..."), array('color' => 'bold_blue'));
     $va_plugin_names = ApplicationPluginManager::getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = ApplicationPluginManager::checkPluginStatus($vs_plugin_name)) {
             CLIUtils::addMessage("\t" . _t("Found %1", $vs_plugin_name));
         }
     }
     CLIUtils::addMessage("\n");
     // Barcode generation
     CLIUtils::addMessage(_t("Checking for barcode dependencies..."), array('color' => 'bold_blue'));
     $vb_gd_is_available = caMediaPluginGDInstalled(true);
     CLIUtils::addMessage("\t(" . _t('GD is a graphics processing library required for all barcode generation.') . ")");
     if (!$vb_gd_is_available) {
         CLIUtils::addError("\t\t" . _t('GD is not installed; barcode printing will not be possible.'));
     } else {
         CLIUtils::addMessage("\t\t" . _t('GD is installed; barcode printing will be available.'));
     }
     CLIUtils::addMessage("\n");
     // General system configuration issues
     CLIUtils::addMessage(_t("Checking system configuration... this may take a while."), array('color' => 'bold_blue'));
     ConfigurationCheck::performExpensive();
     if (ConfigurationCheck::foundErrors()) {
         CLIUtils::addMessage("\t" . _t('Errors were found:'), array('color' => 'bold_red'));
         foreach (ConfigurationCheck::getErrors() as $vn_i => $vs_error) {
             CLIUtils::addError("\t\t[" . ($vn_i + 1) . "] {$vs_error}");
         }
     }
     return true;
 }
 public function DoCheck()
 {
     AssetLoadManager::register('tableList');
     // Search engine
     $vo_search_config_settings = SearchEngine::checkPluginConfiguration();
     $this->view->setVar('search_config_settings', $vo_search_config_settings);
     $this->view->setVar('search_config_engine_name', SearchEngine::getPluginEngineName());
     // Media
     $t_media = new Media();
     $va_plugin_names = $t_media->getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_media->checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('media_config_plugin_list', $va_plugins);
     // PDF Rendering
     $t_pdf_renderer = new PDFRenderer();
     $va_plugin_names = PDFRenderer::getAvailablePDFRendererPlugins();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_pdf_renderer->checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('pdf_renderer_config_plugin_list', $va_plugins);
     // Application plugins
     $va_plugin_names = ApplicationPluginManager::getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = ApplicationPluginManager::checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('application_config_plugin_list', $va_plugins);
     // Barcode generation
     $vb_gd_is_available = caMediaPluginGDInstalled(true);
     $va_barcode_components = array();
     $va_gd = array('name' => 'GD', 'description' => _t('GD is a graphics processing library required for all barcode generation.'));
     if (!$vb_gd_is_available) {
         $va_gd['errors'][] = _t('Is not installed; barcode printing will not be possible.');
     }
     $va_gd['available'] = $vb_gd_is_available;
     $va_barcode_components['GD'] = $va_gd;
     $this->view->setVar('barcode_config_component_list', $va_barcode_components);
     // General system configuration issues
     if (!(bool) $this->request->config->get('dont_do_expensive_configuration_checks_in_web_ui')) {
         ConfigurationCheck::performExpensive();
         if (ConfigurationCheck::foundErrors()) {
             $this->view->setVar('configuration_check_errors', ConfigurationCheck::getErrors());
         }
     }
     $this->render('config_check_html.php');
 }
Exemplo n.º 7
0
 public static function performDatabaseSchemaUpdate()
 {
     $va_messages = array();
     if (($vn_schema_revision = self::getSchemaVersion()) < __CollectiveAccess_Schema_Rev__) {
         for ($vn_i = $vn_schema_revision + 1; $vn_i <= __CollectiveAccess_Schema_Rev__; $vn_i++) {
             if (!($o_updater = ConfigurationCheck::getVersionUpdateInstance($vn_i))) {
                 $o_updater = new GenericVersionUpdater($vn_i);
             }
             $va_methods_that_errored = array();
             // pre-update tasks
             foreach ($o_updater->getPreupdateTasks() as $vs_preupdate_method) {
                 if (!$o_updater->{$vs_preupdate_method}()) {
                     //$va_messages["error_{$vn_i}_{$vs_preupdate_method}_preupdate"] = _t("Pre-update task '{$vs_preupdate_method}' failed");
                     $va_methods_that_errored[] = $vs_preupdate_method;
                 }
             }
             if (is_array($va_new_messages = $o_updater->applyDatabaseUpdate())) {
                 $va_messages = $va_messages + $va_new_messages;
             } else {
                 $va_messages["error_{$vn_i}_sql_fail"] = _t('Could not apply database update for migration %1', $vn_i);
             }
             // post-update tasks
             foreach ($o_updater->getPostupdateTasks() as $vs_postupdate_method) {
                 if (!$o_updater->{$vs_postupdate_method}()) {
                     //$va_messages["error_{$vn_i}_{$vs_postupdate_method}_postupdate"] = _t("Post-update task '{$vs_postupdate_method}' failed");
                     $va_methods_that_errored[] = $vs_postupdate_method;
                 }
             }
             if ($vs_message = $o_updater->getPostupdateMessage()) {
                 $va_messages[(sizeof($va_methods_that_errored) ? "error" : "info") . "_{$vn_i}_{$vs_postupdate_method}_postupdate_message"] = _t("For migration %1", $vn_i) . ": {$vs_message}";
             } else {
                 if (sizeof($va_methods_that_errored)) {
                     $va_messages["error_{$vn_i}_{$vs_postupdate_method}_postupdate_message"] = _t("For migration %1", $vn_i) . ": " . _t("The following tasks did not complete: %1", join(', ', $va_methods_that_errored));
                 } else {
                     $va_messages["info_{$vn_i}_postupdate"] = _t("Applied migration %1", $vn_i);
                 }
             }
         }
     }
     // Clean cache
     caRemoveDirectory(__CA_APP_DIR__ . '/tmp', false);
     return $va_messages;
 }
if (!file_exists('./setup.php')) {
    die("ERROR: Can't load setup.php. Please create the file in the same directory as this script or create a symbolic link to the one in your web root.\n");
}
$_SERVER['HTTP_HOST'] = $argv[1];
require_once "./setup.php";
require_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php";
if ($argv[1]) {
    $o_config_check = new ConfigurationCheck();
    if (($vn_current_revision = ConfigurationCheck::getSchemaVersion()) < __CollectiveAccess_Schema_Rev__) {
        //print "Are you sure you want to update your CollectiveAccess database from revision {$vn_current_revision} to ".__CollectiveAccess_Schema_Rev__."?\nNOTE: you should backup your database before applying updates!\n\nType 'y' to proceed or 'N' to cancel, then hit return ";
        //flush();
        //ob_flush();
        //$confirmation  =  trim( fgets( STDIN ) );
        //if ( $confirmation !== 'y' ) {
        // The user did not say 'y'.
        //	exit (0);
        //}
        $va_messages = ConfigurationCheck::performDatabaseSchemaUpdate();
        print "\n\n";
        print "[" . $argv[1] . "] Applying database migrations...\n";
        foreach ($va_messages as $vs_message) {
            print "\t{$vs_message}\n";
        }
    } else {
        print "[" . $argv[1] . "] Database already at revision " . __CollectiveAccess_Schema_Rev__ . ". No update is required.\n";
    }
} else {
    foreach ($va_systems as $vs_host => $va_system_info) {
        passthru('php ./updateDatabaseSchema.php ' . $vs_host, $vn_ret_);
    }
}