-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhistory.php
More file actions
executable file
·212 lines (204 loc) · 13.4 KB
/
history.php
File metadata and controls
executable file
·212 lines (204 loc) · 13.4 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
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
<?php
// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: history.php,v 1.35 2015-05-27 09:56:27 apetithomme Exp $
//Transmission ensuite du fichier converti
$base_path = ".";
$base_auth = "CATALOGAGE_AUTH";
$base_title = "\$msg[histo_title]";
$base_nobody=1;
include($base_path."/includes/error_report.inc.php") ;
if ($_POST["act"]=="export") {
if (isset($_POST["sel"])) $base_noheader=1;
$base_nosession=0;
// ATTENTION : était à 1 pour permettre l'envoi du header et pas du ccokie avant, bug IE mais finalement, marche arrière...
}
require($base_path."/includes/init.inc.php");
if ($act) {
switch ($act) {
case 'del':
require_once($base_path."/includes/history_functions.inc.php");
//parcours du tableau des recherches de l'historique cochées
for ($i=0;$i<=count($sel)-1;$i++) {
$t1=array();
$t1=suppr_histo($sel[$i]-1,$t1);
$t1=reorg_tableau_suppr($t1);
foreach ($t1 as $key => $value) {
if ($key!=$value) {
$_SESSION["session_history"][$value]=$_SESSION["session_history"][$key];
if ($_SESSION["session_history"][$value]["NOTI"]["SEARCH_TYPE"]=="extended") {
for ($j=0;$j<=count($_SESSION["session_history"][$value]["NOTI"]["POST"]["search"])-1;$j++) {
if ($_SESSION["session_history"][$value]["NOTI"]["POST"]["search"][$j]=="s_1") {
$t2=array();
$t2[0]=$t1[$_SESSION["session_history"][$key]["NOTI"]["POST"]["field_".$j."_".$_SESSION["session_history"][$key]["NOTI"]["POST"]["search"][$j]][0]];
$_SESSION["session_history"][$value]["NOTI"]["POST"]["field_".$j."_".$_SESSION["session_history"][$value]["NOTI"]["POST"]["search"][$j]][0]=$t2[0];
$_SESSION["session_history"][$value]["QUERY"]["POST"]["field_".$j."_".$_SESSION["session_history"][$value]["QUERY"]["POST"]["search"][$j]][0]=$t2[0];
}
}
}
$_SESSION["session_history"][$key]=array();
unset($_SESSION["session_history"][$key]);
}
}
}
$_SESSION["CURRENT"]=$_SESSION["session_history"][count($_SESSION["session_history"])];
break;
case 'delall':
$_SESSION["session_history"]=array();
$_SESSION["CURRENT"]=false;
//vide également l'historique stocké en base
$requete="delete from admin_session where userid=".SESSuserid;
$r=pmb_mysql_query($requete);
break;
case 'export':
if ($sel) {
header("Content-Type: text/txt");
header('Content-Disposition: attachment; filename="search.rsh"');
$export=array();
$f=0;
for ($i=0; $i<count($sel); $i++) {
$export[$f]=$_SESSION["session_history"][$sel[$i]-1];
$f++;
for ($j=0;$j<=count($_SESSION["session_history"])-1;$j++) {
if ($_SESSION["session_history"][$j]["NOTI"]["SEARCH_TYPE"]=="extended") {
for ($x=0;$x<=count($_SESSION["session_history"][$j]["NOTI"]["POST"]["search"])-1;$x++) {
if ($_SESSION["session_history"][$j]["NOTI"]["POST"]["search"][$x]=="s_1") {
if ($_SESSION["session_history"][$j]["NOTI"]["POST"]["field_".$x."_".$_SESSION["session_history"][$j]["NOTI"]["POST"]["search"][$x]][0]==$sel[$i]-1) {
$export[$f]=$_SESSION["session_history"][$j];
$export[$f]["NOTI"]["POST"]["field_".$x."_".$_SESSION["session_history"][$j]["NOTI"]["POST"]["search"][$x]][0]=$f-1;
$export[$f]["QUERY"]["POST"]["field_".$x."_".$_SESSION["session_history"][$j]["QUERY"]["POST"]["search"][$x]][0]=$f-1;
$f++;
}
}
}
}
}
}
$export_serialized=serialize($export);
print $export_serialized;
exit();
} else {
$alert=htmlentities($msg["no_search_selected"],ENT_QUOTES,$charset);
}
break;
case 'import':
print "<body class='catalog'><div id='contenu-frame'><table width='100%'><tr><td align='left'><h3>".$msg["histo_import_title"]."</h3></td><td align='right'><a href='#' onClick=\"parent.document.getElementById('history').style.display='none'; return false;\"><img src='images/close.gif' border='0' align='center'></a></td></tr></table>";
print "<form name='history_form' method='post' action='history.php?act=import2' enctype='multipart/form-data' class='form-catalog'>";
print "<div class='form-contenu'>";
print $msg["histo_select_file"]."<br />";
print "<input type='file' name='search_file'/><br /><br />";
print "</div>";
print "<center><input type='submit' value='".$msg["histo_import_button"]."' class='bouton'/> <input type='button' value='".$msg["print_cancel"]."' class='bouton' onClick=\"document.location='history.php'; return false;\"/></center>";
print "</form>";
print "</div></body>";
print "</html>";
exit();
break;
case 'import2':
$error=false;
if ($_FILES['search_file']['tmp_name']) {
$fp=@fopen($_FILES['search_file']['tmp_name'],'r');
if ($fp) {
$searches=fread($fp,filesize($_FILES['search_file']['tmp_name']));
$import=unserialize($searches);
if ($import) {
for ($i=0; $i<count($import); $i++) {
for ($x=0;$x<=count($import[$i]["NOTI"]["POST"]["search"])-1;$x++) {
if ($import[$i]["NOTI"]["POST"]["search"][$x]=="s_1") {
$import[$i]["NOTI"]["POST"]["field_".$x."_".$import[$i]["NOTI"]["POST"]["search"][$x]][0]=$import[$i]["NOTI"]["POST"]["field_".$x."_".$import[$i]["NOTI"]["POST"]["search"][$x]][0]+count($_SESSION["session_history"]);
$import[$i]["QUERY"]["POST"]["field_".$x."_".$import[$i]["QUERY"]["POST"]["search"][$x]][0]=$import[$i]["QUERY"]["POST"]["field_".$x."_".$import[$i]["QUERY"]["POST"]["search"][$x]][0]+count($_SESSION["session_history"]);
}
}
}
for ($i=0; $i<count($import); $i++) {
$_SESSION["session_history"][]=$import[$i];
}
} else $error=true;
fclose($fp);
unlink($_FILES['search_file']['tmp_name']);
} else $error=true;
} else $error=true;
if ($error) $alert=$msg["histo_upload_failed"];
break;
case 'save':
$save=serialize($_SESSION['session_history']);
$requete="replace into admin_session values(".SESSuserid.",'".addslashes($save)."')";
$r=pmb_mysql_query($requete);
if (!$r) $alert=$msg["histo_save_fail"]; else $alert=$msg["histo_save_done"];
break;
}
}
print "<body class='catalog'><div id='contenu-frame'><table width='100%'><tr><td align='left'><h3>".$msg["histo_title"]."</h3></td><td align='right'><a href='#' onClick=\"parent.document.getElementById('history').style.display='none'; return false;\"><img src='images/close.gif' border='0' align='center'></a></td></tr></table>";
print "<form name='history_form' method='post' action='history.php'>";
if ($alert) {
print "<script>alert(\"".$alert."\")</script>";
}
print "<input type='hidden' name='act' value=''/>";
if (count($_SESSION["session_history"])) {
print $begin_result_liste." ";
print "<a href='#' onClick=\"document.history_form.act.value='del'; document.history_form.submit(); return false;\"><img src='images/suppr_coche.gif' alt=\"".$msg["histo_del_selected"]."\" title=\"".$msg["histo_del_selected"]."\" /></a> ";
print "<a href='#' onClick=\"document.history_form.act.value='delall'; document.history_form.submit(); return false;\"><img src='images/suppr_all.gif' alt=\"".$msg["histo_del_histo"]."\" title=\"".$msg["histo_del_histo"]."\" /></a> ";
print " <a href='#' onClick=\"document.history_form.act.value='save'; document.history_form.submit(); return false;\"><img src='images/save.gif' alt=\"".$msg["histo_save_histo"]."\" title=\"".$msg["histo_save_histo"]."\" /></a> ";
print " <a href='#' onClick=\"document.history_form.act.value='export'; document.history_form.submit(); return false;\"><img src='images/upload.gif' alt=\"".$msg["histo_export_selected"]."\" title=\"".$msg["histo_export_selected"]."\" /></a> ";
print " <a href='#' onClick=\"document.history_form.act.value='import'; document.history_form.submit(); return false;\"><img src='images/download.gif' alt=\"".$msg["histo_import_searches"]."\" title=\"".$msg["histo_import_searches"]."\" /></a><br />";
for ($i=count($_SESSION["session_history"])-1; $i>=0; $i--) {
$javascript_template ="
<div id=\"el!!id!!Parent\" class=\"notice-parent\">
<input type='checkbox' name='sel[]' value='".($i+1)."'/><img src=\"./images/plus.gif\" class=\"img_plus\" name=\"imEx\" id=\"el!!id!!Img\" title=\"".addslashes($msg['plus_detail'])."\" border=\"0\" onClick=\"expandBase('el!!id!!', true); return false;\" hspace=\"3\">
<span class=\"notice-heada\">!!query!!</span>
<br />
</div>
<div id=\"el!!id!!Child\" !!sO!! class=\"notice-child\" style=\"margin-bottom:6px;width:auto;border:none;display:none;\">
!!subqueries!!
</div>";
$query_prep=($i+1).")";
if (!$_SESSION["session_history"][$i]["QUERY"]["NOLINK"]) $query_prep.=" <a href='#' onClick=\"parent.document.location='recall.php?t=QUERY¤t=$i'; return false;\">";
$query_prep.=$_SESSION["session_history"][$i]["QUERY"]["HUMAN_TITLE"]." : ".$_SESSION["session_history"][$i]["QUERY"]["HUMAN_QUERY"];
if (!$_SESSION["session_history"][$i]["QUERY"]["NOLINK"]) $query_prep.="</a>";
$to_print=str_replace("!!query!!",$query_prep,$javascript_template);
$subqueries="";
if (($_SESSION["session_history"][$i]["AUT"])||($_SESSION["session_history"][$i]["NOTI"])||($_SESSION["session_history"][$i]["EXPL"])||($_SESSION["session_history"][$i]["EMPR"])) {
$subqueries.="<table width='100%' id='history_table'>";
if (($_SESSION["session_history"][$i]["AUT"])&&($_SESSION["session_history"][$i]["NOTI"])) {
$image="./images/branch.png";
$background="./images/branch_background.png";
} else {
$image="./images/branch_final.png";
$background="";
}
if ($_SESSION["session_history"][$i]["AUT"]) $subqueries.="<tr><td width='15px' valign='top' style=\"background:url('$background') repeat-y;\"><img src='$image' align='center'/></td><td><a href='#' onClick=\"parent.document.location='recall.php?t=AUT¤t=$i'; return false;\"><b>A</b> ".$_SESSION["session_history"][$i]["AUT"]["HUMAN_QUERY"].", page ".$_SESSION["session_history"][$i]["AUT"]["PAGE"]."</a></td></tr>\n";
if ($_SESSION["session_history"][$i]["NOTI"]) {
$subqueries.="<tr><td width='15' valign='top'><img src='./images/branch_final.png' align='center'/></td><td><a href='#' onClick=\"parent.document.location='recall.php?t=NOTI¤t=$i'; return false;\"><b>N</b> ".$_SESSION["session_history"][$i]["NOTI"]["HUMAN_QUERY"].", page ".$_SESSION["session_history"][$i]["NOTI"]["PAGE"]."</a>";
if (!$_SESSION["session_history"][$i]["NOTI"]["NOPRINT"])
$subqueries.=" <a href='#' onClick=\"openPopUp('./print_cart.php?current_print=$i&action=print_prepare','print',500, 600, -2, -2, 'scrollbars=yes,menubar=0'); return false;\"><img src='./images/basket_small_20x20.gif' border='0' align='center' alt=\"".$msg["histo_add_to_cart"]."\" title=\"".$msg["histo_add_to_cart"]."\"></a> <a href='#' onClick=\"w=openPopUp('./print.php?current_print=$i&action_print=print_prepare','print',500,600,-2,-2,'scrollbars=yes,menubar=0'); return false;\"><img src='./images/print.gif' border='0' align='center' alt=\"".$msg["histo_print"]."\" title=\"".$msg["histo_print"]."\"/></a>";
$subqueries.=" <a href='#' onClick=\"openPopUp('./download.php?current_download=$i&action_download=download_prepare','download',500,600,-2,-2,'scrollbars=yes,menubar=0'); return false;\"><img src='./images/upload_docnum.gif' border='0' align='center' alt=\"".$msg["docnum_download"]."\" title=\"".$msg["docnum_download"]."\"/></a>";
if ($pmb_allow_external_search)
$subqueries.=" <a href='#' onClick=\"parent.document.location='recall.php?t=NOTI¤t=$i&external=1'; return false;\" title='".$msg["connecteurs_external_search_sources"]."'><img src='./images/external_search.png' border='0' align='center' alt=\"".$msg["connecteurs_external_search_sources"]."\"/></a>";
$subqueries.="</td></tr>\n";
}
if ($_SESSION["session_history"][$i]["EXPL"]) {
$subqueries.="<tr><td width='15' valign='top'><img src='./images/branch_final.png' align='center'/></td><td><a href='#' onClick=\"parent.document.location='recall.php?t=EXPL¤t=$i'; return false;\"><b>N</b> ".$_SESSION["session_history"][$i]["EXPL"]["HUMAN_QUERY"].", page ".$_SESSION["session_history"][$i]["EXPL"]["PAGE"]."</a>";
$subqueries.="</td></tr>\n";
}
if ($_SESSION["session_history"][$i]["EMPR"]) {
$subqueries.="<tr><td width='15' valign='top'><img src='./images/branch_final.png' align='center'/></td><td><a href='#' onClick=\"parent.document.location='recall.php?t=EMPR¤t=$i'; return false;\"><b>N</b> ".$_SESSION["session_history"][$i]["EMPR"]["HUMAN_QUERY"].", page ".$_SESSION["session_history"][$i]["EMPR"]["PAGE"]."</a>";
$subqueries.="</td></tr>\n";
}
$subqueries.="</table>";
}
$to_print=str_replace("!!subqueries!!",$subqueries,$to_print);
$to_print=str_replace("!!id!!",$i+1,$to_print);
if (($_SESSION["CURRENT"]!==false)&&($_SESSION["CURRENT"]==$i))
$to_print=str_replace("!!sO!!","startOpen=\"Yes\"",$to_print);
else
$to_print=str_replace("!!sO!!","",$to_print);
print pmb_bidi($to_print);
}
} else {
print "<b>".$msg["histo_empty"]."</b><br />";
print "<a href='#' onClick=\"document.history_form.act.value='import'; document.history_form.submit(); return false;\"><img src='images/download.gif' alt=\"".$msg["histo_import_searches"]."\" title=\"".$msg["histo_import_searches"]."\" align='center'/></a><br />";
}
print "</form>";
print "</div></body></html>";
?>