-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport.php
More file actions
executable file
·166 lines (156 loc) · 7.46 KB
/
export.php
File metadata and controls
executable file
·166 lines (156 loc) · 7.46 KB
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
<?php
// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: export.php,v 1.7.4.1 2015-09-10 07:58:28 jpermanne Exp $
// définition du minimum nécéssaire
$base_path=".";
$base_auth = "ADMINISTRATION_AUTH|CATALOGAGE_AUTH";
$base_title = "";
$base_noheader=1;
$base_nosession=1;
require_once ("$base_path/includes/init.inc.php");
switch($quoi) {
// Export de procédures
case "procs":
switch($sub) {
case "caddie" :
header("Content-Type: application/download\n");
header("Content-Disposition: atachement; filename=\"caddie_proc_".$id.".sql\"");
$req="select type, name, requete, comment, autorisations, parameters from caddie_procs where idproc='$id' ";
$res = pmb_mysql_query($req,$dbh);
if ($p=pmb_mysql_fetch_object($res)) {
$exp="INSERT INTO caddie_procs set type='".addslashes($p->type)."', name='".addslashes($p->name)."', requete='".addslashes($p->requete)."', comment='".addslashes($p->comment)."', autorisations='1', parameters='".addslashes($p->parameters)."' ";
//nettoyage de l'entête des paramètres, pour les anciennes procédures
if($charset=='utf-8'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', '<?xml version=\"1.0\" encoding=\"utf-8\"?>', $exp) ;
}elseif($charset=='iso-8859-1'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"utf-8\"?>', '<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', $exp) ;
}
//tag pour l'encodage du contenu
$exp .= "\n#charset=".$charset;
echo $exp ;
}
break;
case "empr_caddie" :
header("Content-Type: application/download\n");
header("Content-Disposition: atachement; filename=\"empr_caddie_proc_".$id.".sql\"");
$req="select type, name, requete, comment, autorisations, parameters from empr_caddie_procs where idproc='$id' ";
$res = pmb_mysql_query($req,$dbh);
if ($p=pmb_mysql_fetch_object($res)) {
$exp="INSERT INTO empr_caddie_procs set type='".addslashes($p->type)."', name='".addslashes($p->name)."', requete='".addslashes($p->requete)."', comment='".addslashes($p->comment)."', autorisations='1', parameters='".addslashes($p->parameters)."' ";
//nettoyage de l'entête des paramètres, pour les anciennes procédures
if($charset=='utf-8'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', '<?xml version=\"1.0\" encoding=\"utf-8\"?>', $exp) ;
}elseif($charset=='iso-8859-1'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"utf-8\"?>', '<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', $exp) ;
}
//tag pour l'encodage du contenu
$exp .= "\n#charset=".$charset;
echo $exp ;
}
break;
case "actionsperso" :
header("Content-Type: application/download\n");
header("Content-Disposition: atachement; filename=\"admin_proc_".$id.".sql\"");
$req="select name, requete, comment, autorisations, parameters from procs where idproc='$id' ";
$res = pmb_mysql_query($req,$dbh);
if ($p=pmb_mysql_fetch_object($res)) {
$exp="INSERT INTO procs set name='".addslashes($p->name)."', requete='".addslashes($p->requete)."', comment='".addslashes($p->comment)."', autorisations='1', parameters='".addslashes($p->parameters)."' ";
//nettoyage de l'entête des paramètres, pour les anciennes procédures
if($charset=='utf-8'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', '<?xml version=\"1.0\" encoding=\"utf-8\"?>', $exp) ;
}elseif($charset=='iso-8859-1'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"utf-8\"?>', '<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', $exp) ;
}
//tag pour l'encodage du contenu
$exp .= "\n#charset=".$charset;
echo $exp ;
}
break;
}
break;
case "stat" :
header("Content-Type: application/download\n");
header("Content-Disposition: atachement; filename=\"admin_stat_".$id_req.".sql\"");
$req="SELECT * from statopac_request WHERE idproc='$id_req' ";
$res = pmb_mysql_query($req,$dbh);
if ($p=pmb_mysql_fetch_object($res)) {
$requete=$p->requete;
$exp="INSERT INTO statopac_request set name='".addslashes($p->name)."', requete='".addslashes($requete)."', comment='".addslashes($p->comment)."', parameters='".addslashes($p->parameters)."' ";
//nettoyage de l'entête des paramètres, pour les anciennes procédures
if($charset=='utf-8'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', '<?xml version=\"1.0\" encoding=\"utf-8\"?>', $exp) ;
}elseif($charset=='iso-8859-1'){
$exp = str_replace('<?xml version=\"1.0\" encoding=\"utf-8\"?>', '<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>', $exp) ;
}
//Colonnes vue
$req2="SELECT nom_col, expression, filtre, datatype FROM statopac_vues_col WHERE num_vue=".$p->num_vue." ORDER BY LENGTH(nom_col) DESC";
$res2 = pmb_mysql_query($req2,$dbh);
while ($p2=pmb_mysql_fetch_object($res2)) {
if(preg_match('`[^a-zA-Z0-9\_]'.$p2->nom_col.'[^a-zA-Z0-9\_]`',$requete)){
$arrayTmp=array();
$arrayTmp[]=$p2->nom_col;
$arrayTmp[]=$p2->expression;
$arrayTmp[]=$p2->filtre;
$arrayTmp[]=$p2->datatype;
$exp .= "\n#col=".serialize($arrayTmp);
}
}
//tag pour l'encodage du contenu
$exp .= "\n#charset=".$charset;
echo $exp ;
}
break;
case "notice_tpl" :
header("Content-Type: application/download\n");
header("Content-Disposition: atachement; filename=\"notice_tpl_".$id.".tpl\"");
$exp = '';
$array_loc=array();
$req="SELECT * from notice_tpl WHERE notpl_id='$id' ";
$res = pmb_mysql_query($req,$dbh);
if ($p=pmb_mysql_fetch_object($res)) {
$requete=$p->requete;
$array_tmp=array();
$array_tmp[]=array("field"=>'notpl_name',"value"=>$p->notpl_name);
$array_tmp[]=array("field"=>'notpl_code',"value"=>$p->notpl_code);
$array_tmp[]=array("field"=>'notpl_comment',"value"=>$p->notpl_comment);
if (trim($exp)) {
$exp .= "\n";
}
$exp .= "#main#=".serialize($array_tmp);
$req2="SELECT * from notice_tplcode WHERE num_notpl='$id' ";
$res2 = pmb_mysql_query($req2,$dbh);
$array_sub=array();
while ($p2=pmb_mysql_fetch_object($res2)) {
$array_tmp=array();
$array_tmp[]=array("field"=>'notplcode_localisation',"value"=>$p2->notplcode_localisation);
$array_tmp[]=array("field"=>'notplcode_typdoc',"value"=>$p2->notplcode_typdoc);
$array_tmp[]=array("field"=>'notplcode_niveau_biblio',"value"=>$p2->notplcode_niveau_biblio);
$array_tmp[]=array("field"=>'notplcode_niveau_hierar',"value"=>$p2->notplcode_niveau_hierar);
$array_tmp[]=array("field"=>'nottplcode_code',"value"=>$p2->nottplcode_code);
$array_sub[]=$array_tmp;
if($p2->notplcode_localisation){
if(!count($array_loc)||!in_array($p2->notplcode_localisation,$array_loc)){
$array_loc[]=$p2->notplcode_localisation;
}
}
}
$exp .= "\n#sub#=".serialize($array_sub);
//localisations
if(count($array_loc)){
$array_tmp=array();
foreach($array_loc as $id_loc){
$res=pmb_mysql_query("SELECT location_libelle FROM docs_location WHERE idlocation=".$id_loc);
$row=pmb_mysql_fetch_object($res);
$array_tmp[]=array("id_location"=>$id_loc,"lib_location"=>$row->location_libelle);
}
$exp .= "\n#locations#=".serialize($array_tmp);
}
//tag pour l'encodage du contenu
$exp .= "\n#charset#=".$charset;
echo $exp ;
}
break;
}
pmb_mysql_close($dbh);