<?php /** * @file * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs). */ /** * Defines the root directory of the Backdrop installation. * * The dirname() function is used to get path to Backdrop root folder, which * avoids resolving of symlinks. This allows the code repository to be a symlink * and hosted outside of the web root. See issue #1297. */ define('BACKDROP_ROOT', dirname(dirname($_SERVER['SCRIPT_FILENAME']))); // Change the directory to the Backdrop root. chdir(BACKDROP_ROOT); include_once BACKDROP_ROOT . '/core/includes/bootstrap.inc'; backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); if (!isset($_GET['cron_key']) || state_get('cron_key') != $_GET['cron_key']) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); backdrop_access_denied(); } elseif (state_get('maintenance_mode', FALSE)) { watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE); backdrop_access_denied(); } else { backdrop_cron_run(); }
/** * Execute the BackdropBoot::BOOTSTRAP_FULL phase. */ function bootstrap_backdrop_full() { if (!drush_get_context('DRUSH_QUIET', FALSE)) { ob_start(); } backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); if (!drush_get_context('DRUSH_QUIET', FALSE)) { ob_end_clean(); } }
/** * Load Backdrop bootstrap. * * @param array $params * Either uid, or name & pass. * @param bool $loadUser * Boolean Require CMS user load. * @param bool $throwError * If true, print error on failure and exit. * @param bool|string $realPath path to script * * @return bool */ public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { $cmsPath = $this->cmsRootPath($realPath); if (!file_exists("{$cmsPath}/core/includes/bootstrap.inc")) { if ($throwError) { echo '<br />Sorry, could not locate bootstrap.inc\\n'; exit; } return FALSE; } // load drupal bootstrap chdir($cmsPath); define('BACKDROP_ROOT', $cmsPath); // For drupal multi-site CRM-11313 if ($realPath && strpos($realPath, 'sites/all/modules/') === FALSE) { preg_match('@sites/([^/]*)/modules@s', $realPath, $matches); if (!empty($matches[1])) { $_SERVER['HTTP_HOST'] = $matches[1]; } } require_once "{$cmsPath}/core/includes/bootstrap.inc"; backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); // Explicitly setting error reporting, since we cannot handle Backdrop // related notices. error_reporting(1); if (!function_exists('module_exists') || !module_exists('civicrm')) { if ($throwError) { echo '<br />Sorry, could not load Backdrop bootstrap.'; exit; } return FALSE; } // Backdrop successfully bootstrapped. $config = CRM_Core_Config::singleton(); // lets also fix the clean url setting // CRM-6948 $config->cleanURL = (int) config_get('system.core', 'clean_url'); // we need to call the config hook again, since we now know // all the modules that are listening on it, does not apply // to J! and WP as yet // CRM-8655 CRM_Utils_Hook::config($config); if (!$loadUser) { return TRUE; } $uid = CRM_Utils_Array::value('uid', $params); if (!$uid) { // Load the user we need to check Backdrop permissions. $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); $pass = CRM_Utils_Array::value('pass', $params, FALSE) ? $params['pass'] : trim(CRM_Utils_Array::value('pass', $_REQUEST)); if ($name) { $uid = user_authenticate($name, $pass); if (!$uid) { if ($throwError) { echo '<br />Sorry, unrecognized username or password.'; exit; } return FALSE; } } } if ($uid) { $account = user_load($uid); if ($account && $account->uid) { global $user; $user = $account; return TRUE; } } if ($throwError) { echo '<br />Sorry, can not load CMS user account.'; exit; } // CRM-6948: When using loadBootStrap, it's implicit that CiviCRM has already loaded its settings // which means that define(CIVICRM_CLEANURL) was correctly set. // So we correct it $config = CRM_Core_Config::singleton(); $config->cleanURL = (int) config_get('system.core', 'clean_url'); // CRM-8655: Backdrop wasn't available during bootstrap, so // hook_civicrm_config() never executes. CRM_Utils_Hook::config($config); return FALSE; }
* @return * TRUE if the current user can run authorize.php, and FALSE if not. */ function authorize_access_allowed() { return settings_get('allow_authorize_operations', TRUE) && user_access('administer software updates'); } // *** Real work of the script begins here. *** require_once BACKDROP_ROOT . '/core/includes/bootstrap.inc'; require_once BACKDROP_ROOT . '/core/includes/common.inc'; require_once BACKDROP_ROOT . '/core/includes/file.inc'; require_once BACKDROP_ROOT . '/core/includes/module.inc'; require_once BACKDROP_ROOT . '/core/includes/ajax.inc'; // We prepare only a minimal bootstrap. This includes the database and // variables, however, so we have access to the class autoloader registry. backdrop_bootstrap(BACKDROP_BOOTSTRAP_SESSION); // This must go after backdrop_bootstrap(), which unsets globals! global $conf; // We have to enable the user and system modules, even to check access and // display errors via the maintenance theme. $module_list['system']['filename'] = 'core/modules/system/system.module'; $module_list['user']['filename'] = 'core/modules/user/user.module'; module_list(TRUE, FALSE, FALSE, $module_list); backdrop_load('module', 'system'); backdrop_load('module', 'user'); // We also want to have the language system available, but we do *NOT* want to // actually call backdrop_bootstrap(BACKDROP_BOOTSTRAP_LANGUAGE), since that would // also force us through the BACKDROP_BOOTSTRAP_PAGE_HEADER phase, which loads // all the modules, and that's exactly what we're trying to avoid. backdrop_language_initialize(); // Initialize the maintenance theme for this administrative script.
/** * @param $config * * @return mixed */ public function install($config) { global $installDirPath; // create database if does not exists $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']); global $installDirPath; // Build database require_once $installDirPath . 'civicrm.php'; civicrm_main($config); if (!$this->errors) { global $installType, $installURLPath; $registerSiteURL = "https://civicrm.org/register-site"; $commonOutputMessage = "<li>" . ts("Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a %1>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume mailing list).", array(1 => "href='{$registerSiteURL}' target='_blank'")) . "</li>" . "<li>" . ts("We have integrated KCFinder with CKEditor and TinyMCE. This allows a user to upload images. All uploaded images are public.") . "</li>"; $output = NULL; if ($installType == 'drupal' && version_compare(VERSION, '7.0-rc1') >= 0) { // clean output @ob_clean(); $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; $output .= '<head>'; $output .= '<title>' . ts('CiviCRM Installed') . '</title>'; $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $output .= '<link rel="stylesheet" type="text/css" href="template.css" />'; $output .= '</head>'; $output .= '<body>'; $output .= '<div style="padding: 1em;"><p class="good">' . ts('CiviCRM has been successfully installed') . '</p>'; $output .= '<ul>'; $drupalURL = civicrm_cms_base(); $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/people/permissions"; $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>"; $output .= $commonOutputMessage; // automatically enable CiviCRM module once it is installed successfully. // so we need to Bootstrap Drupal, so that we can call drupal hooks. global $cmsPath, $crmPath; // relative / abosolute paths are not working for drupal, hence using chdir() chdir($cmsPath); // Force the re-initialisation of the config singleton on the next call // since so far, we had used the Config object without loading the DB. $c = CRM_Core_Config::singleton(FALSE); $c->free(); include_once "./includes/bootstrap.inc"; include_once "./includes/unicode.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // prevent session information from being saved. drupal_save_session(FALSE); // Force the current user to anonymous. $original_user = $GLOBALS['user']; $GLOBALS['user'] = drupal_anonymous_user(); // explicitly setting error reporting, since we cannot handle drupal related notices error_reporting(1); // rebuild modules, so that civicrm is added system_rebuild_module_data(); // now enable civicrm module. module_enable(array('civicrm', 'civicrmtheme')); // clear block, page, theme, and hook caches drupal_flush_all_caches(); //add basic drupal permissions civicrm_install_set_drupal_perms(); // restore the user. $GLOBALS['user'] = $original_user; drupal_save_session(TRUE); //change the default language to one chosen if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') { civicrm_api3('Setting', 'create', array('domain_id' => 'current_domain', 'lcMessages' => $config['seedLanguage'])); } $output .= '</ul>'; $output .= '</div>'; $output .= '</body>'; $output .= '</html>'; echo $output; } elseif ($installType == 'backdrop') { // clean output @ob_clean(); $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; $output .= '<head>'; $output .= '<title>' . ts('CiviCRM Installed') . '</title>'; $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $output .= '<link rel="stylesheet" type="text/css" href="template.css" />'; $output .= '</head>'; $output .= '<body>'; $output .= '<div style="padding: 1em;"><p class="good">' . ts('CiviCRM has been successfully installed') . '</p>'; $output .= '<ul>'; $backdropURL = civicrm_cms_base(); $backdropPermissionsURL = "{$backdropURL}index.php?q=admin/config/people/permissions"; $backdropURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Backdrop user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$backdropPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$backdropURL}'")) . "</li>"; $output .= $commonOutputMessage; // automatically enable CiviCRM module once it is installed successfully. // so we need to Bootstrap Drupal, so that we can call drupal hooks. global $cmsPath, $crmPath; // relative / abosolute paths are not working for drupal, hence using chdir() chdir($cmsPath); // Force the re-initialisation of the config singleton on the next call // since so far, we had used the Config object without loading the DB. $c = CRM_Core_Config::singleton(FALSE); $c->free(); include_once "./core/includes/bootstrap.inc"; include_once "./core/includes/unicode.inc"; backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); // prevent session information from being saved. backdrop_save_session(FALSE); // Force the current user to anonymous. $original_user = $GLOBALS['user']; $GLOBALS['user'] = backdrop_anonymous_user(); // explicitly setting error reporting, since we cannot handle drupal related notices error_reporting(1); // rebuild modules, so that civicrm is added system_rebuild_module_data(); // now enable civicrm module. module_enable(array('civicrm', 'civicrmtheme')); // clear block, page, theme, and hook caches backdrop_flush_all_caches(); //add basic backdrop permissions civicrm_install_set_backdrop_perms(); // restore the user. $GLOBALS['user'] = $original_user; backdrop_save_session(TRUE); //change the default language to one chosen if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') { civicrm_api3('Setting', 'create', array('domain_id' => 'current_domain', 'lcMessages' => $config['seedLanguage'])); } $output .= '</ul>'; $output .= '</div>'; $output .= '</body>'; $output .= '</html>'; echo $output; } elseif ($installType == 'drupal' && version_compare(VERSION, '6.0') >= 0) { // clean output @ob_clean(); $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; $output .= '<head>'; $output .= '<title>' . ts('CiviCRM Installed') . '</title>'; $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $output .= '<link rel="stylesheet" type="text/css" href="template.css" />'; $output .= '</head>'; $output .= '<body>'; $output .= '<div style="padding: 1em;"><p class="good">' . ts("CiviCRM has been successfully installed") . '</p>'; $output .= '<ul>'; $drupalURL = civicrm_cms_base(); $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions"; $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>"; $output .= $commonOutputMessage; // explicitly setting error reporting, since we cannot handle drupal related notices error_reporting(1); // automatically enable CiviCRM module once it is installed successfully. // so we need to Bootstrap Drupal, so that we can call drupal hooks. global $cmsPath, $crmPath; // relative / abosolute paths are not working for drupal, hence using chdir() chdir($cmsPath); // Force the re-initialisation of the config singleton on the next call // since so far, we had used the Config object without loading the DB. $c = CRM_Core_Config::singleton(FALSE); $c->free(); include_once "./includes/bootstrap.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // rebuild modules, so that civicrm is added module_rebuild_cache(); // now enable civicrm module. module_enable(array('civicrm')); // clear block, page, theme, and hook caches drupal_flush_all_caches(); //add basic drupal permissions db_query('UPDATE {permission} SET perm = CONCAT( perm, \', access CiviMail subscribe/unsubscribe pages, access all custom data, access uploaded files, make online contributions, profile create, profile edit, profile view, register for events, view event info\') WHERE rid IN (1, 2)'); echo $output; } elseif ($installType == 'wordpress') { echo '<h1>' . ts('CiviCRM Installed') . '</h1>'; echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">' . ts("CiviCRM has been successfully installed") . '</p>'; echo '<ul>'; $cmsURL = civicrm_cms_base(); $cmsURL .= "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/configtask&reset=1"; $wpPermissionsURL = "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/access/wp-permissions&reset=1"; $output .= "<li>" . ts("WordPress user permissions have been automatically set - giving Anonymous and Subscribers access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$wpPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$cmsURL}'")) . "</li>"; $output .= $commonOutputMessage; echo '</ul>'; echo '</div>'; $c = CRM_Core_Config::singleton(FALSE); $c->free(); $wpInstallRedirect = admin_url("?page=CiviCRM&q=civicrm&reset=1"); echo "<script>\n window.location = '{$wpInstallRedirect}';\n </script>"; } } return $this->errors; }
header("Cache-Control: store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", FALSE); // Serve the contents. $file = file_get_contents($full_path); // Old release xml files are missing the encoding. Prepend one if necessary. if (substr($file, 0, 5) != '<?xml') { echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; } echo $file; // Record usage statistics. if (isset($_GET['site_key'])) { if (!chdir(BACKDROP_ROOT)) { exit(1); } include_once './core/includes/bootstrap.inc'; backdrop_bootstrap(BACKDROP_BOOTSTRAP_DATABASE); // We can't call module_exists without bootstrapping to a higher level so // we'll settle for checking that the table exists. if (db_table_exists('project_usage_raw')) { $site_key = $_GET['site_key']; $project_version = isset($_GET['version']) ? $_GET['version'] : ''; $ip_address = ip_address(); // Compute a GMT timestamp for beginning of the day. getdate() is // affected by the server's timezone so we need to cancel it out. $now = time(); $time_parts = getdate($now - date('Z', $now)); $timestamp = gmmktime(0, 0, 0, $time_parts['mon'], $time_parts['mday'], $time_parts['year']); $result = db_query("UPDATE {project_usage_raw} SET version_api = :version_api, version = :version, hostname = :hostname WHERE name = :name AND timestamp = :timestamp AND site_key = :site_key", array(':version_api' => $version_api, ':version' => $project_version, ':hostname' => $ip_address, ':name' => $project_name, ':timestamp' => $timestamp, ':site_key' => $site_key)); if ($result->rowCount() === 0) { db_query("INSERT INTO {project_usage_raw} (name, timestamp, site_key, version_api, version, hostname) VALUES (:name, :timestamp, :site_key, :version_api, :version, :hostname)", array(':name' => $project_name, ':timestamp' => $timestamp, ':site_key' => $site_key, ':version_api' => $version_api, ':version' => $project_version, ':hostname' => $ip_address)); }