<commit_before><?php

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'],basename(__FILE__)) !== false) {
  header('location: index.php');
  exit;
}

switch ($db_tiki) {
	case 'postgres7':
	case 'postgres8':
		$db_tiki = 'pgsql';
		break;
	case 'mysqli':
		$db_tiki = 'mysql';
		break;
	case 'oracle':
		$db_tiki = 'oci';
}

if ($db_tiki == 'sybase') {
	// avoid database change messages
	ini_set('sybct.min_server_severity', '11');
}

$dbTiki = new PDO("$db_tiki:host=$host_tiki;dbname=$dbs_tiki", $user_tiki, $pass_tiki);
$dbTiki->setAttribute(PDO::ATTR_CASE,PDO::CASE_NATURAL);
$dbTiki->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$dbTiki->setAttribute(PDO::ATTR_ORACLE_NULLS,PDO::NULL_EMPTY_STRING);
//$dbTiki->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,false);
//if ($dbTiki->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
//	$dbTiki->setAttribute(array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
//}


$pq = $dbTiki->prepare('select `login` from `users_users` limit 1');
$result = $pq->execute();
$pq->closeCursor();

if ( $result === FALSE ) {
	print '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Error: Unable to connect to the database !</title>
	<link rel="stylesheet" href="styles/tikineat.css" type="text/css">
</head>
<body >
	<div id="tiki-main">
		<div id="tiki-mid">
			<div style="margin:10px 30px;">
				<h1><font color="red">Tikiwiki is unable to connect to the database.</font> <a title="help" href="http://doc.tikiwiki.org/Installation" target="help"><img border="0" src="img/icons/help.gif" alt="Help" /></a></h1>
';
	print '<p>The following error message was returned:<div class="simplebox">';
	$errors = $dbTiki->errorInfo();
	print $errors[2];<commit_msg>[FIX] fix PDO for MySQL and UTF-8<commit_after><?php

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'],basename(__FILE__)) !== false) {
  header('location: index.php');
  exit;
}

switch ($db_tiki) {
	case 'postgres7':
	case 'postgres8':
		$db_tiki = 'pgsql';
		break;
	case 'mysqli':
		$db_tiki = 'mysql';
		break;
	case 'oracle':
		$db_tiki = 'oci';
}

if ($db_tiki == 'sybase') {
	// avoid database change messages
	ini_set('sybct.min_server_severity', '11');
}

$dbTiki = new PDO("$db_tiki:host=$host_tiki;dbname=$dbs_tiki", $user_tiki, $pass_tiki);
$dbTiki->setAttribute(PDO::ATTR_CASE,PDO::CASE_NATURAL);
$dbTiki->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$dbTiki->setAttribute(PDO::ATTR_ORACLE_NULLS,PDO::NULL_EMPTY_STRING);
//$dbTiki->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,false);
if ($dbTiki->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
	$dbTiki->exec("SET CHARACTER SET utf8");
}


$pq = $dbTiki->prepare('select `login` from `users_users` limit 1');
$result = $pq->execute();
$pq->closeCursor();

if ( $result === FALSE ) {
	print '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Error: Unable to connect to the database !</title>
	<link rel="stylesheet" href="styles/tikineat.css" type="text/css">
</head>
<body >
	<div id="tiki-main">
		<div id="tiki-mid">
			<div style="margin:10px 30px;">
				<h1><font color="red">Tikiwiki is unable to connect to the database.</font> <a title="help" href="http://doc.tikiwiki.org/Installation" target="help"><img border="0" src="img/icons/help.gif" alt="Help" /></a></h1>
';
	print '<p>The following error message was returned:<div class="simplebox">';
	$errors = $dbTiki->errorInfo();
	print $errors[2];
{'fraction_non_alphanumeric': 0.20217230313502838, 'fraction_numerical': 0.014564305109849419, 'mean_word_length': 5.856175972927242, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 2, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288604', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1569, 'n_words': 301}