If you have moved an existing CiviCRM installation from one location or server to another there are several steps you will need to follow. They are detailed on this CiviCRM wiki page - {$docLink}. A fix for the specific problem that caused this error message to be displayed is to set the value of the config_backend column in the civicrm_domain table to NULL. However we strongly recommend that you review and follow all the steps in that document.
"; CRM_Utils_System::civiExit(); } else { return FALSE; } } return TRUE; } /** * delete a directory given a path name, delete children directories * and files if needed * * @param string $path the path name * * @return void * @access public * @static */ static function cleanDir($target, $rmdir = TRUE, $verbose = TRUE) { static $exceptions = array('.', '..'); if ($target == '' || $target == '/') { throw new Exception("Overly broad deletion"); } if ($sourcedir = @opendir($target)) { while (FALSE !== ($sibling = readdir($sourcedir))) { if (!in_array($sibling, $exceptions)) { $object = $target . DIRECTORY_SEPARATOR . $sibling; if (is_dir($object)) { CRM_Utils_File::cleanDir($object, $rmdir, $verbose); } elseif (is_file($object)) { if (!unlink($object)) { CRM_Core_Session::setStatus(ts('Unable to remove file %1', array(1 => $object)), ts('Warning'), 'error'); } } } } closedir($sourcedir); if ($rmdir) { if (rmdir($target)) { if ($verbose) { CRM_Core_Session::setStatus(ts('Removed directory %1', array(1 => $target)), '', 'success'); } return TRUE; } else { CRM_Core_Session::setStatus(ts('Unable to remove directory %1', array(1 => $target)), ts('Warning'), 'error'); } } } } static function copyDir($source, $destination) { $dir = opendir($source); @mkdir($destination); while (FALSE !== ($file = readdir($dir))) { if (($file != '.') && ($file != '..')) { if (is_dir($source . DIRECTORY_SEPARATOR . $file)) { CRM_Utils_File::copyDir($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file); } else { copy($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file); } } } closedir($dir); } /** * Given a file name, recode it (in place!) to UTF-8 * * @param string $name name of file * * @return boolean whether the file was recoded properly * @access public */ static function toUtf8($name) { static $config = NULL; static $legacyEncoding = NULL; if ($config == NULL) { $config = CRM_Core_Config::singleton(); $legacyEncoding = $config->legacyEncoding; } if (!function_exists('iconv')) { return FALSE; } $contents = file_get_contents($name); if ($contents === FALSE) { return FALSE; } $contents = iconv($legacyEncoding, 'UTF-8', $contents); if ($contents === FALSE) { return FALSE; } $file = fopen($name, 'w'); if ($file === FALSE) { return FALSE; } $written = fwrite($file, $contents); $closed = fclose($file); if ($written === FALSE or !$closed) { return FALSE; } return TRUE; } /** * Appends trailing slashed to paths * * @return string * @access public * @static */ static function addTrailingSlash($name, $separator = NULL) { if (!$separator) { $separator = DIRECTORY_SEPARATOR; } if (substr($name, -1, 1) != $separator) { $name .= $separator; } return $name; } static function sourceSQLFile($dsn, $fileName, $prefix = NULL, $isQueryString = FALSE, $dieOnErrors = TRUE) { require_once 'DB.php'; $db = DB::connect($dsn); if (PEAR::isError($db)) { die("Cannot open $dsn: " . $db->getMessage()); } if (CRM_Utils_Constant::value('CIVICRM_MYSQL_STRICT', CRM_Utils_System::isDevelopment())) { $db->query('SET SESSION sql_mode = STRICT_TRANS_TABLES'); } if (!$isQueryString) { $string = $prefix . file_get_contents($fileName); } else { // use filename as query string $string = $prefix . $fileName; } //get rid of comments starting with # and -- $string = preg_replace("/^#[^\n]*$/m", "\n", $string); $string = preg_replace("/^(--[^-]).*/m", "\n", $string); $queries = preg_split('/;\s*$/m', $string); foreach ($queries as $query) { $query = trim($query); if (!empty($query)) { CRM_Core_Error::debug_query($query); $res = &$db->query($query); if (PEAR::isError($res)) { if ($dieOnErrors) { die("Cannot execute $query: " . $res->getMessage()); } else { echo "Cannot execute $query: " . $res->getMessage() . "";
}
}
}
}
}
static function isExtensionSafe($ext) {
static $extensions = NULL;
if (!$extensions) {
$extensions = CRM_Core_OptionGroup::values('safe_file_extension', TRUE);
//make extensions to lowercase
$extensions = array_change_key_case($extensions, CASE_LOWER);
// allow html/htm extension ONLY if the user is admin
// and/or has access CiviMail
if (!(CRM_Core_Permission::check('access CiviMail') ||
CRM_Core_Permission::check('administer CiviCRM') ||
(CRM_Mailing_Info::workflowEnabled() &&
CRM_Core_Permission::check('create mailings')
)
)) {
unset($extensions['html']);
unset($extensions['htm']);
}
}
//support lower and uppercase file extensions
return isset($extensions[strtolower($ext)]) ? TRUE : FALSE;
}
/**
* Determine whether a given file is listed in the PHP include path
*
* @param string $name name of file
*
* @return boolean whether the file can be include()d or require()d
*/
static function isIncludable($name) {
$x = @fopen($name, 'r', TRUE);
if ($x) {
fclose($x);
return TRUE;
}
else {
return FALSE;
}
}
/**
* remove the 32 bit md5 we add to the fileName
* also remove the unknown tag if we added it
*/
static function cleanFileName($name) {
// replace the last 33 character before the '.' with null
$name = preg_replace('/(_[\w]{32})\./', '.', $name);
return $name;
}
static function makeFileName($name) {
$uniqID = md5(uniqid(rand(), TRUE));
$info = pathinfo($name);
$basename = substr($info['basename'],
0, -(strlen(CRM_Utils_Array::value('extension', $info)) + (CRM_Utils_Array::value('extension', $info) == '' ? 0 : 1))
);
if (!self::isExtensionSafe(CRM_Utils_Array::value('extension', $info))) {
// munge extension so it cannot have an embbeded dot in it
// The maximum length of a filename for most filesystems is 255 chars.
// We'll truncate at 240 to give some room for the extension.
return CRM_Utils_String::munge("{$basename}_" . CRM_Utils_Array::value('extension', $info) . "_{$uniqID}", '_', 240) . ".unknown";
}
else {
return CRM_Utils_String::munge("{$basename}_{$uniqID}", '_', 240) . "." . CRM_Utils_Array::value('extension', $info);
}
}
static function getFilesByExtension($path, $ext) {
$path = self::addTrailingSlash($path);
$dh = opendir($path);
$files = array();
while (FALSE !== ($elem = readdir($dh))) {
if (substr($elem, -(strlen($ext) + 1)) == '.' . $ext) {
$files[] .= $path . $elem;
}
}
closedir($dh);
return $files;
}
/**
* Restrict access to a given directory (by planting there a restrictive .htaccess file)
*
* @param string $dir the directory to be secured
*/
static function restrictAccess($dir) {
// note: empty value for $dir can play havoc, since that might result in putting '.htaccess' to root dir
// of site, causing site to stop functioning.
// FIXME: we should do more checks here -
if (!empty($dir)) {
$htaccess = <<