-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.inc.php
248 lines (220 loc) · 6.4 KB
/
config.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
date_default_timezone_set("Europe/Paris");
$pathClangToLog="logs/2012-01-12/";
$pathGCCToLog="rebuild.lsid64-amd64.2011-09-11";
$suffix="lsid64b";
$ext="buildlog";
$currentVersion="10.0.0";
$clangVersions=Array(
"2.9" => 16398,
"3.0" => 15658,
"3.1" => 17710,
"3.2" => 18264,
"3.3" => 18854,
"3.4" => 21204,
"3.4.2" => 21383,
"3.5.0" => 22202,
"3.6.0" => 22319,
"3.8.1" => 24585,
"3.9.1" => 27828,
"4.0.1" => 27828,
"5.0" => 28203,
"6.0" => 32304,
"8.0.1" => 31169,
"9.0.1" => 31169,
"10.0.0" => 31014,
"11.0.0" => 32432,
);
$locally_configured = false;
if (file_exists("local-config.inc.php")) {
include("local-config.inc.php");
}
if (!$locally_configured) {
switch ($_SERVER['HTTP_HOST']){
case 'clang.debian.net':
case 'manchot.ecranbleu.org':
include("clang.debian.net.php");
define("BASEPATH","/www/clang.debian.net/");
$pathSite="/www/clang.debian.net/";
$pathToBaseDocumentations="{$pathSite}docs/";
$base="/";
define("_DEBUG_MAIL_","[email protected]");
$nom_emetteur="Site Sylvestre";
$adr_emetteur="[email protected]";
$type="MYSQL";
$ATOMSdbAvailable=true;
break;
case 'localhost':
define("_DB_","clang");
define("_DB_HOST_","localhost");
define("_DB_USER_","clang");
define("_DB_PASS_","aze");
$pathSite="/var/www/clang/";
$pathToBaseDocumentations="{$pathSite}docs/";
$base="/";
define("_DEBUG_MAIL_","[email protected]");
$nom_emetteur="Site Sylvestre";
$adr_emetteur="[email protected]";
$type="MYSQL";
break;
default:
define("_DB_","Unknow");
define("_DB_HOST_","Unknow");
define("_DB_USER_","Unknow");
define("_DB_PASS_","Unknow");
print "Le fichier config.inc.php n'est pas configure ";
print "({$_SERVER['HTTP_HOST']})";
exit;
}
}
$secureMode = false;
if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == "X.Y.Z.W") {
$secureMode = true;
}
$host_db = _DB_HOST_;
$user_db = _DB_USER_;
$pass_db = _DB_PASS_;
//$port_db = _DB_PORT_;
$db_db = _DB_;
$use_mysqli = false;
if (defined("PHP_MAJOR_VERSION") && PHP_MAJOR_VERSION >= 7) {
$use_mysqli = true;
function mysql_connect($host_db,$user_db,$pass_db) {
$mysqli = new mysqli($host_db,$user_db,$pass_db);
if ($mysqli->connect_error) {
die("Connect Error (".$mysqli->connect_errno.") "
.$mysqli->connect_error);
}
return $mysqli;
}
function mysql_error() {
global $conn_db;
return $conn_db->error;
}
function mysql_fetch_object($result) {
return $result->fetch_object();
}
function mysql_query($req) {
global $conn_db;
return $conn_db->query($req);
}
function mysql_select_db($db_db,$conn_db) {
return $conn_db->select_db($db_db);
}
}
switch ($type) {
case "POSTGRESQL" :
$chaine_connexion="host=$host_db port=$port_db dbname=$db_db user=$user_db password=$pass_db";
$conn = pg_pconnect($chaine_connexion);
echo pg_errormessage($conn);
break;
case "MYSQL" :
$conn_db = @mysql_connect("$host_db","$user_db","$pass_db");
if( !@mysql_select_db("$db_db",$conn_db) ){
// echo ("Erreur dans la selection de la base de données $db_db -> $user_db@$host_db.\n");
echo mysql_error();
}
break;
}
function db_query ($req)
{
// Fonction "surcouche" e mysql_query () qui ajoute la gestion d'erreur
global $type;
global $conn;
switch ($type) {
case "POSTGRESQL" :
if ( $sth=pg_exec($conn,$req) ) {
return $sth;
} else {
echo pg_errormessage($conn);
error_req($req);
}
break;
case "MYSQL" :
if ( $sth=mysql_query("$req") )
{
// la requete s'est bien passé
// affichage de la requete si le verbose est activé
return $sth;
}
else
{
// Erreur dans la requete, donc génération du mail.
echo mysql_error();
error_req($req);
}
}
}
function error_req ($req) {
global $PHP_SELF;
global $REQUEST_URI;
global $REMOTE_ADDR;
global $type;
global $HTTP_REFERER;
global $HTTP_USER_AGENT;
$to=_DEBUG_MAIL_;
switch ($type) {
case "POSTGRESQL" :
global $conn;
$sgbd=pg_errormessage($conn);
break;
case "MYSQL" :
$sgbd=mysql_error();
break;
}
$subject="SQL query - Error";
$body="Query : $req \nPage : $PHP_SELF \nError : ".$sgbd;
$body.="\nRequested Url : $REQUEST_URI";
$body.="\nGet :\n".parray($_GET)."\nPost :\n".parray($_POST)."\nSession :\n".parray($_SESSION);
$body.="\nReferent : $HTTP_REFERER\nUser Agent : $HTTP_USER_AGENT\nAdresse distante : $REMOTE_ADDR ( ".gethostbyaddr($REMOTE_ADDR)." )\n";
mail($to,$subject,$body);
}
/*
* Retour une représentation des éléments d'un tableau
* $array : le tableau à afficher
* $prep : le séparateur à utiliser
* return : le tableau ainsi généré
*/
if (!function_exists("parray")){
function parray($array , $prep=''){
$ret="";
$prep = "$prep|";
if (is_array($array) || is_object($array)) {
if (is_object($array))
$array=get_object_vars($array);
while(list($key, $val) = each($array)) {
$type = gettype($val);
if(is_array($val)) {
$line = "-+ $key ($type)\n";
$line .= parray($val, "$prep ");
} else {
if (is_object($val)) { // C'est un object
$line = "-+ $key ($type)\n";
$line .= parray(get_object_vars($val),"$prep ");
}else {
$line = "=> $key = \"$val\" ($type)\n";
}
}
$ret .= $prep.$line;
}
}
return $ret;
}
}
function SendMail($adr_destinataire,$sujet,$corps) {
// l'émetteur
global $nom_emetteur;
global $adr_emetteur;
$tete = "From: ".$nom_emetteur." <".$adr_emetteur.">\n";
$tete .= "Reply-To: ".$adr_emetteur."\n";
// false si erreur d'émission
return mail($adr_destinataire,$sujet,$corps,$tete);
}
function makeSummary($text, $nbchar) {
if (strlen($text)>$nbchar) {
return substr($text,0,$nbchar)." (...)";
}else{
return $text;
}
}
?>