/
record.php
1672 lines (1453 loc) · 83.1 KB
/
record.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./record.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 29-Jul-02, 16:39
// Modified: $Date$
// $Author$
// $Revision$
// Form that offers to add
// records or edit/delete
// existing ones.
// Incorporate some include files:
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
include 'includes/header.inc.php'; // include header
include 'includes/footer.inc.php'; // include footer
include 'includes/include.inc.php'; // include common functions
include 'initialize/ini.inc.php'; // include common variables
// --------------------------------------------------------------------
// START A SESSION:
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
start_session(true);
// --------------------------------------------------------------------
// Initialize preferred display language:
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
include 'includes/locales.inc.php'; // include the locales
// --------------------------------------------------------------------
// Extract session variables:
if (isset($_SESSION['errors']))
{
$errors = $_SESSION['errors']; // read session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current error message is still available to this script via '$errors':
deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
else
$errors = array(); // initialize the '$errors' variable in order to prevent 'Undefined variable...' messages
if (isset($_SESSION['formVars']))
{
$formVars = $_SESSION['formVars']; // read session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current form variables are still available to this script via '$formVars':
deleteSessionVariable("formVars"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
else
$formVars = array();
// Read out import data that were saved as a session variable:
// NOTE: This is done by 'import_modify.php' (if a single record was imported via the web interface) in order to retain
// large param/value strings (that would exceed the maximum string limit for GET requests). This works around a limitation
// in Internet Explorer which has a maximum URL length of 2,083 characters & a maximum path length of 2,048 characters.
// More info: <http://support.microsoft.com/kb/208427/EN-US/>
if (isset($_SESSION['importData']))
{
foreach ($_SESSION['importData'] as $varname => $value)
{
$_POST[$varname] = $value;
$_REQUEST[$varname] = $value;
}
deleteSessionVariable("importData"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
// --------------------------------------------------------------------
if (isset($_REQUEST['recordAction']))
$recordAction = $_REQUEST['recordAction']; // check whether the user wants to *add* a record or *edit* an existing one
else
$recordAction = ""; // if the 'recordAction' parameter wasn't set we set the '$recordAction' variable to the empty string ("") to prevent 'Undefined index: recordAction...' notification messages
if (isset($_REQUEST['mode']))
$mode = $_REQUEST['mode']; // check whether the user wants to add a record by use of an *import* form (e.g., the parameter "mode=import" will be set by 'import_modify.php' and 'import_csa_modify.php')
else
$mode = ""; // if the 'mode' parameter wasn't set we set the '$mode' variable to the empty string ("") to prevent 'Undefined index: mode...' notification messages
if (isset($_REQUEST['importSource']))
$importSource = $_REQUEST['importSource']; // get the source from which the imported data originate (e.g., if data have been imported via 'import_csa.php', the 'importSource' value will be 'csa')
else
$importSource = ""; // if the 'importSource' parameter wasn't set we set the '$importSource' variable to the empty string ("") to prevent 'Undefined index: importSource...' notification messages
if (isset($_REQUEST['serialNo']))
$serialNo = $_REQUEST['serialNo']; // fetch the serial number of the record to edit
else
$serialNo = ""; // this is actually unneccessary, but we do it for clarity reasons here
// Setup some required variables:
// If there's no stored message available:
if (!isset($_SESSION['HeaderString'])) // if there's no stored message available
{
if (empty($errors)) // provide one of the default messages:
{
$errors = array(); // re-assign an empty array (in order to prevent 'Undefined variable "errors"...' messages when calling the 'fieldError' function later on)
if ($recordAction == "edit") // *edit* record
$HeaderString = $loc["EditRecordHeaderText"] . ":";
else // *add* record will be the default action if no parameter is given
{
$HeaderString = $loc["AddRecordHeaderText"];
if (isset($_REQUEST['source'])) // when importing data, we display the original source data if the 'source' parameter is present:
$HeaderString .= ". Original source data:\n<br>\n<br>\n<code>" . encodeHTML($_REQUEST['source']) . "</code>"; // the 'source' parameter gets passed by 'import.php' or 'import_csa.php'
else
$HeaderString .= ":";
}
}
else // -> there were errors validating the data entered by the user
$HeaderString = "<b><span class=\"warning\">". $loc["Warning_InputDataError"]."</span></b>";
}
else // there is already a stored message available
{
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
// ('' will produce the default 'Web' output style)
if (isset($_REQUEST['viewType']))
$viewType = $_REQUEST['viewType'];
else
$viewType = "";
// if the user isn't logged in -OR- any normal user is logged in (not the admin)...
if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
{
$fieldLock = " readonly"; // ... lock the 'location' & 'file' fields
$fieldLockLabel = " (" . $loc["readonly"] . ")"; // ... append a " (readonly)" indicator to the field description of the 'location' & 'file' fields
}
else // if the admin is logged in...
{
$fieldLock = ""; // ...the 'location' & 'file' fields won't be locked (since the admin should be able to freely add or edit any records)
$fieldLockLabel = "";
}
if ($recordAction == "edit") // *edit* record
{
$pageTitle = $loc["EditRecord"]; // set the correct page title
$addEditButtonTitle = $loc["ButtonTitle_EditRecord"]; // set the button name of the (default) submit button ('Edit Record')
}
else
{
$recordAction = "add"; // *add* record will be the default action if no parameter is given
$pageTitle = $loc["AddRecord"]; // set the correct page title
$addEditButtonTitle = $loc["ButtonTitle_AddRecord"]; // set the button name of the (default) submit button ('Add Record')
$serialNo = $loc["not assigned yet"];
// if the user isn't logged in -OR- any normal user is logged in (not the admin)...
if ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail)))
// ...provide a generic info string within the (locked) 'location' field that informs the user about the automatic fill in of his user name & email address
// (IMPORTANT: if you change this information string you must also edit the corresponding 'preg_match(...)' pattern in 'modify.php'!)
$locationName = $loc["your name & email address will be filled in automatically"];
else // if the admin is logged in...
$locationName = ""; // ...keep the 'location' field empty
}
if (isset($loginEmail)) // if a user is logged in
{
// build a correct call number prefix for the currently logged-in user (e.g. 'IPÖ @ msteffens'):
$callNumberPrefix = getCallNumberPrefix(); // function 'getCallNumberPrefix()' is defined in 'include.inc.php'
}
// Build HTML elements that allow for auto-completions of text entered by the user:
if (isset($_SESSION['userAutoCompletions']) AND ($_SESSION['userAutoCompletions'] == "yes"))
{
$authorSuggestElements = buildSuggestElements("authorName", "authorSuggestions", "authorSuggestProgress", "col-author-", "\t\t", "';'"); // function 'buildSuggestElements()' is defined in 'include.inc.php'
$titleSuggestElements = buildSuggestElements("titleName", "titleSuggestions", "titleSuggestProgress", "col-title-");
$yearSuggestElements = buildSuggestElements("yearNo", "yearSuggestions", "yearSuggestProgress", "col-year-");
$publicationSuggestElements = buildSuggestElements("publicationName", "publicationSuggestions", "publicationSuggestProgress", "col-publication-");
$abbrevJournalSuggestElements = buildSuggestElements("abbrevJournalName", "abbrevJournalSuggestions", "abbrevJournalSuggestProgress", "col-abbrev_journal-");
$volumeSuggestElements = buildSuggestElements("volumeNo", "volumeSuggestions", "volumeSuggestProgress", "col-volume-");
$issueSuggestElements = buildSuggestElements("issueNo", "issueSuggestions", "issueSuggestProgress", "col-issue-");
$pagesSuggestElements = buildSuggestElements("pagesNo", "pagesSuggestions", "pagesSuggestProgress", "col-pages-");
$keywordsSuggestElements = buildSuggestElements("keywordsName", "keywordsSuggestions", "keywordsSuggestProgress", "col-keywords-", "\t\t", "';'");
$addressSuggestElements = buildSuggestElements("addressName", "addressSuggestions", "addressSuggestProgress", "col-address-", "\t\t", "';'");
$corporateAuthorSuggestElements = buildSuggestElements("corporateAuthorName", "corporateAuthorSuggestions", "corporateAuthorSuggestProgress", "col-corporate_author-", "\t\t", "';'");
$publisherSuggestElements = buildSuggestElements("publisherName", "publisherSuggestions", "publisherSuggestProgress", "col-publisher-");
$placeSuggestElements = buildSuggestElements("placeName", "placeSuggestions", "placeSuggestProgress", "col-place-", "\t\t", "[';',',']");
$editorSuggestElements = buildSuggestElements("editorName", "editorSuggestions", "editorSuggestProgress", "col-editor-", "\t\t", "';'");
$languageSuggestElements = buildSuggestElements("languageName", "languageSuggestions", "languageSuggestProgress", "col-language-", "\t\t", "';'");
$summaryLanguageSuggestElements = buildSuggestElements("summaryLanguageName", "summaryLanguageSuggestions", "summaryLanguageSuggestProgress", "col-summary_language-", "\t\t", "';'");
$origTitleSuggestElements = buildSuggestElements("origTitleName", "origTitleSuggestions", "origTitleSuggestProgress", "col-orig_title-");
$seriesEditorSuggestElements = buildSuggestElements("seriesEditorName", "seriesEditorSuggestions", "seriesEditorSuggestProgress", "col-series_editor-", "\t\t", "';'");
$seriesTitleSuggestElements = buildSuggestElements("seriesTitleName", "seriesTitleSuggestions", "seriesTitleSuggestProgress", "col-series_title-");
$abbrevSeriesTitleSuggestElements = buildSuggestElements("abbrevSeriesTitleName", "abbrevSeriesTitleSuggestions", "abbrevSeriesTitleSuggestProgress", "col-abbrev_series_title-");
$seriesVolumeSuggestElements = buildSuggestElements("seriesVolumeNo", "seriesVolumeSuggestions", "seriesVolumeSuggestProgress", "col-series_volume-");
$seriesIssueSuggestElements = buildSuggestElements("seriesIssueNo", "seriesIssueSuggestions", "seriesIssueSuggestProgress", "col-series_issue-");
$editionSuggestElements = buildSuggestElements("editionNo", "editionSuggestions", "editionSuggestProgress", "col-edition-");
$issnSuggestElements = buildSuggestElements("issnName", "issnSuggestions", "issnSuggestProgress", "col-issn-");
$isbnSuggestElements = buildSuggestElements("isbnName", "isbnSuggestions", "isbnSuggestProgress", "col-isbn-");
$mediumSuggestElements = buildSuggestElements("mediumName", "mediumSuggestions", "mediumSuggestProgress", "col-medium-");
$areaSuggestElements = buildSuggestElements("areaName", "areaSuggestions", "areaSuggestProgress", "col-area-", "\t\t", "';'");
$expeditionSuggestElements = buildSuggestElements("expeditionName", "expeditionSuggestions", "expeditionSuggestProgress", "col-expedition-", "\t\t", "';'");
$conferenceSuggestElements = buildSuggestElements("conferenceName", "conferenceSuggestions", "conferenceSuggestProgress", "col-conference-");
$notesSuggestElements = buildSuggestElements("notesName", "notesSuggestions", "notesSuggestProgress", "col-notes-", "\t\t", "';'");
if ((isset($loginEmail)) AND ($loginEmail == $adminLoginEmail)) // admin logged in
{
$locationSuggestElements = buildSuggestElements("locationName", "locationSuggestions", "locationSuggestProgress", "col-location-", "\t\t", "';'");
$callNumberSuggestElements = buildSuggestElements("callNumberName", "callNumberSuggestions", "callNumberSuggestProgress", "col-call_number-", "\t\t", "[';','@']");
}
else // user isn't logged in -OR- any normal user is logged in
{
$locationSuggestElements = "";
$callNumberSuggestElements = buildSuggestElements("callNumberNameUserOnly", "callNumberSuggestions", "callNumberSuggestProgress", "col-call_number-", "\t\t", "[';','@']");
}
$userKeysSuggestElements = buildSuggestElements("userKeysName", "userKeysSuggestions", "userKeysSuggestProgress", "col-user_keys-", "\t\t", "';'");
$userNotesSuggestElements = buildSuggestElements("userNotesName", "userNotesSuggestions", "userNotesSuggestProgress", "col-user_notes-", "\t\t", "';'");
$userFileSuggestElements = buildSuggestElements("userFileName", "userFileSuggestions", "userFileSuggestProgress", "col-user_file-");
$userGroupsSuggestElements = buildSuggestElements("userGroupsName", "userGroupsSuggestions", "userGroupsSuggestProgress", "col-user_groups-", "\t\t", "';'");
$citeKeySuggestElements = buildSuggestElements("citeKeyName", "citeKeySuggestions", "citeKeySuggestProgress", "col-cite_key-");
$relatedSuggestElements = buildSuggestElements("relatedName", "relatedSuggestions", "relatedSuggestProgress", "col-related-", "\t\t", "';'");
$urlSuggestElements = buildSuggestElements("urlName", "urlSuggestions", "urlSuggestProgress", "col-url-");
$doiSuggestElements = buildSuggestElements("doiName", "doiSuggestions", "doiSuggestProgress", "col-doi-");
$onlineCitationSuggestElements = buildSuggestElements("onlineCitationName", "onlineCitationSuggestions", "onlineCitationSuggestProgress", "col-online_citation-");
}
else
{
$authorSuggestElements = "";
$titleSuggestElements = "";
$yearSuggestElements = "";
$publicationSuggestElements = "";
$abbrevJournalSuggestElements = "";
$volumeSuggestElements = "";
$issueSuggestElements = "";
$pagesSuggestElements = "";
$keywordsSuggestElements = "";
$addressSuggestElements = "";
$corporateAuthorSuggestElements = "";
$publisherSuggestElements = "";
$placeSuggestElements = "";
$editorSuggestElements = "";
$languageSuggestElements = "";
$summaryLanguageSuggestElements = "";
$origTitleSuggestElements = "";
$seriesEditorSuggestElements = "";
$seriesTitleSuggestElements = "";
$abbrevSeriesTitleSuggestElements = "";
$seriesVolumeSuggestElements = "";
$seriesIssueSuggestElements = "";
$editionSuggestElements = "";
$issnSuggestElements = "";
$isbnSuggestElements = "";
$mediumSuggestElements = "";
$areaSuggestElements = "";
$expeditionSuggestElements = "";
$conferenceSuggestElements = "";
$notesSuggestElements = "";
$locationSuggestElements = "";
$callNumberSuggestElements = "";
$userKeysSuggestElements = "";
$userNotesSuggestElements = "";
$userFileSuggestElements = "";
$userGroupsSuggestElements = "";
$citeKeySuggestElements = "";
$relatedSuggestElements = "";
$urlSuggestElements = "";
$doiSuggestElements = "";
$onlineCitationSuggestElements = "";
}
// --------------------------------------------------------------------
// CONSTRUCT SQL QUERY:
// if the script was called with parameters (like: 'record.php?recordAction=edit&serialNo=...')
if ($recordAction == "edit")
{
// for the selected record, select *all* available fields:
$query = buildSELECTclause("Edit", "1"); // function 'buildSELECTclause()' is defined in 'include.inc.php'
if (isset($_SESSION['loginEmail'])) // if a user is logged in, show user specific fields:
$query .= " FROM $tableRefs LEFT JOIN $tableUserData ON serial = record_id AND user_id =" . quote_smart($loginUserID) . " WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$"); // since we'll only fetch one record, the ORDER BY clause is obsolete here
else // if NO user logged in, don't display any user specific fields:
$query .= " FROM $tableRefs WHERE serial RLIKE " . quote_smart("^(" . $serialNo . ")$"); // since we'll only fetch one record, the ORDER BY clause is obsolete here
}
// --------------------------------------------------------------------
// (1) OPEN CONNECTION, (2) SELECT DATABASE
connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
// Initialize some variables (to prevent "Undefined variable..." messages):
$isEditorCheckBox = "";
$contributionIDCheckBox = "";
$locationSelectorName = "";
if ($recordAction == "edit" AND empty($errors))
{
// (3a) RUN the query on the database through the connection:
$result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
if (@ mysql_num_rows($result) == 1) // this condition is added here to avoid the case that clicking on a search result item which got deleted in the meantime invokes a seemingly correct but empty 'edit record' search form
{
// (3b) EXTRACT results:
$row = mysql_fetch_array($result); //fetch the current row into the array $row (it'll be always *one* row, but anyhow)
// fetch attributes of the current record into variables:
$authorName = encodeHTML($row['author']);
$titleName = encodeHTML($row['title']);
$yearNo = encodeHTML($row['year']);
$publicationName = encodeHTML($row['publication']);
$abbrevJournalName = encodeHTML($row['abbrev_journal']);
$volumeNo = encodeHTML($row['volume']);
$issueNo = encodeHTML($row['issue']);
$pagesNo = encodeHTML($row['pages']);
$addressName = encodeHTML($row['address']);
$corporateAuthorName = encodeHTML($row['corporate_author']);
$keywordsName = encodeHTML($row['keywords']);
$abstractName = encodeHTML($row['abstract']);
$publisherName = encodeHTML($row['publisher']);
$placeName = encodeHTML($row['place']);
$editorName = encodeHTML($row['editor']);
$languageName = encodeHTML($row['language']);
$summaryLanguageName = encodeHTML($row['summary_language']);
$origTitleName = encodeHTML($row['orig_title']);
$seriesEditorName = encodeHTML($row['series_editor']);
$seriesTitleName = encodeHTML($row['series_title']);
$abbrevSeriesTitleName = encodeHTML($row['abbrev_series_title']);
$seriesVolumeNo = encodeHTML($row['series_volume']);
$seriesIssueNo = encodeHTML($row['series_issue']);
$editionNo = encodeHTML($row['edition']);
$issnName = encodeHTML($row['issn']);
$isbnName = encodeHTML($row['isbn']);
$mediumName = encodeHTML($row['medium']);
$areaName = encodeHTML($row['area']);
$expeditionName = encodeHTML($row['expedition']);
$conferenceName = encodeHTML($row['conference']);
$notesName = encodeHTML($row['notes']);
$approvedRadio = encodeHTML($row['approved']);
// we only show the contents of the 'location' field if the user is logged in:
// (this is mostly done to shield user email addresses from exposure to search engines and/or email harvesting robots)
if (isset($loginEmail))
{
$locationName = encodeHTML($row['location']);
$rawLocationName = $row['location']; // we'll save the unencoded location string to a separate variable since it will be needed when generating the delete button
}
else
{
$locationName = "";
$rawLocationName = "";
}
$callNumberName = $row['call_number']; // contents of the 'call_number' field will get encoded depending on who's logged in (normal user vs. admin)
// (for normal users being logged in, the field's contents won't get HTML encoded at all, since the data will
// get *rawurlencoded* when including them within a hidden form tag; for the admin being logged in, the data
// will get HTML encoded below)
// if a normal user is logged in, we'll only display the user's *own* call number within the 'call_number' field:
if ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail))
{
if (preg_match("/(^|.*;) *$callNumberPrefix *@ +([^@;]+)/", $callNumberName)) // if the user's call number prefix occurs within the contents of the 'call_number' field
{
$callNumberNameUserOnly = preg_replace("/(^|.*;) *$callNumberPrefix *@ +([^@;]+).*/", "\\2", $callNumberName); // extract the user's *own* call number from the full contents of the 'call_number' field
$callNumberNameUserOnly = encodeHTML($callNumberNameUserOnly);
}
else
$callNumberNameUserOnly = "";
}
elseif ((isset($loginEmail)) AND ($loginEmail == $adminLoginEmail)) // admin logged in
{
$callNumberNameUserOnly = ""; // the 'call_number' field will be empty if no user is logged in (note that '$callNumberNameUserOnly' won't be used at all, if the admin is logged in)
$callNumberName = encodeHTML($callNumberName); // if the admin is logged in we display the full contents of the 'call_number' field, so we'll need to HTML encode the data
}
else // nobody logged in
{
$callNumberNameUserOnly = ""; // the 'call_number' field will be empty if no user is logged in (note that '$callNumberNameUserOnly' won't be used at all, if the admin is logged in)
// note that, as for normal users being logged in, the call number field contents won't get HTML encoded here, since the data will get *rawurlencoded* when including them within a hidden form tag
}
$serialNo = encodeHTML($row['serial']);
$typeName = encodeHTML($row['type']);
$thesisName = encodeHTML($row['thesis']);
if (isset($row['marked'])) // 'marked' field is only provided if a user is logged in
$markedRadio = encodeHTML($row['marked']);
else
$markedRadio = "";
if (isset($row['copy'])) // 'copy' field is only provided if a user is logged in
$copyName = encodeHTML($row['copy']);
else
$copyName = "";
if (isset($row['selected'])) // 'selected' field is only provided if a user is logged in
$selectedRadio = encodeHTML($row['selected']);
else
$selectedRadio = "";
if (isset($row['user_keys'])) // 'user_keys' field is only provided if a user is logged in
$userKeysName = encodeHTML($row['user_keys']);
else
$userKeysName = "";
if (isset($row['user_notes'])) // 'user_notes' field is only provided if a user is logged in
$userNotesName = encodeHTML($row['user_notes']);
else
$userNotesName = "";
if (isset($row['user_file'])) // 'user_file' field is only provided if a user is logged in
$userFileName = encodeHTML($row['user_file']);
else
$userFileName = "";
if (isset($row['user_groups'])) // 'user_groups' field is only provided if a user is logged in
$userGroupsName = encodeHTML($row['user_groups']);
else
$userGroupsName = "";
if (isset($row['cite_key'])) // 'cite_key' field is only provided if a user is logged in
$citeKeyName = encodeHTML($row['cite_key']);
else
$citeKeyName = "";
if (isset($row['related'])) // 'related' field is only provided if a user is logged in
$relatedName = encodeHTML($row['related']);
else
$relatedName = "";
// show the contents of the 'file' field if one of the following conditions is met:
// - the variable '$fileVisibility' (defined in 'ini.inc.php') is set to 'everyone'
// - the variable '$fileVisibility' is set to 'login' AND the user is logged in
// - the variable '$fileVisibility' is set to 'user-specific' AND the 'user_permissions' session variable contains 'allow_download'
if ($fileVisibility == "everyone" OR ($fileVisibility == "login" AND isset($_SESSION['loginEmail'])) OR ($fileVisibility == "user-specific" AND (isset($_SESSION['user_permissions']) AND preg_match("/allow_download/", $_SESSION['user_permissions']))))
$fileName = encodeHTML($row['file']);
else // if the user has no permission to download (and hence view) any files, 'modify.php' will take care that the empty form value won't overwrite any existing contents of the 'file' field
$fileName = "";
$urlName = encodeHTML($row['url']);
$doiName = encodeHTML($row['doi']);
$contributionID = $row['contribution_id'];
$onlinePublication = $row['online_publication'];
$onlineCitationName = $row['online_citation'];
$createdDate = $row['created_date'];
$createdTime = $row['created_time'];
$createdBy = encodeHTML($row['created_by']);
$modifiedDate = $row['modified_date'];
$modifiedTime = $row['modified_time'];
$modifiedBy = encodeHTML($row['modified_by']);
$origRecord = $row['orig_record'];
}
else
showErrorMsg($loc["The Query"].":\n<br>\n<br>\n<code>" . encodeHTML($query) . "</code>\n<br>\n<br>\n ". $loc["caused an error"].":", "");
}
else // if ($recordAction == "add") -OR- ($recordAction == "edit" but there were some errors on submit)
{
if ($recordAction == "add" AND $mode == "import" AND empty($errors)) // if the user wants to import record data by use of an import form (like 'import.php' or 'import_csa.php')
{
foreach($_REQUEST as $varname => $value)
// remove slashes from parameter values if 'magic_quotes_gpc = On':
$_REQUEST[$varname] = stripSlashesIfMagicQuotes($value); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php'
// read field data from a GET/POST request:
if (isset($_REQUEST['author']))
$authorName = encodeHTML($_REQUEST['author']);
else
$authorName = "";
if (isset($_REQUEST['title']))
$titleName = encodeHTML($_REQUEST['title']);
else
$titleName = "";
if (isset($_REQUEST['year']))
$yearNo = encodeHTML($_REQUEST['year']);
else
$yearNo = "";
if (isset($_REQUEST['publication']))
$publicationName = encodeHTML($_REQUEST['publication']);
else
$publicationName = "";
if (isset($_REQUEST['abbrev_journal']))
$abbrevJournalName = encodeHTML($_REQUEST['abbrev_journal']);
else
$abbrevJournalName = "";
if (isset($_REQUEST['volume']))
$volumeNo = encodeHTML($_REQUEST['volume']);
else
$volumeNo = "";
if (isset($_REQUEST['issue']))
$issueNo = encodeHTML($_REQUEST['issue']);
else
$issueNo = "";
if (isset($_REQUEST['pages']))
$pagesNo = encodeHTML($_REQUEST['pages']);
else
$pagesNo = "";
if (isset($_REQUEST['address']))
$addressName = encodeHTML($_REQUEST['address']);
else
$addressName = "";
if (isset($_REQUEST['corporate_author']))
$corporateAuthorName = encodeHTML($_REQUEST['corporate_author']);
else
$corporateAuthorName = "";
if (isset($_REQUEST['keywords']))
$keywordsName = encodeHTML($_REQUEST['keywords']);
else
$keywordsName = "";
if (isset($_REQUEST['abstract']))
$abstractName = encodeHTML($_REQUEST['abstract']);
else
$abstractName = "";
if (isset($_REQUEST['publisher']))
$publisherName = encodeHTML($_REQUEST['publisher']);
else
$publisherName = "";
if (isset($_REQUEST['place']))
$placeName = encodeHTML($_REQUEST['place']);
else
$placeName = "";
if (isset($_REQUEST['editor']))
$editorName = encodeHTML($_REQUEST['editor']);
else
$editorName = "";
if (isset($_REQUEST['language']))
$languageName = encodeHTML($_REQUEST['language']);
else
$languageName = "";
if (isset($_REQUEST['summary_language']))
$summaryLanguageName = encodeHTML($_REQUEST['summary_language']);
else
$summaryLanguageName = "";
if (isset($_REQUEST['orig_title']))
$origTitleName = encodeHTML($_REQUEST['orig_title']);
else
$origTitleName = "";
if (isset($_REQUEST['series_editor']))
$seriesEditorName = encodeHTML($_REQUEST['series_editor']);
else
$seriesEditorName = "";
if (isset($_REQUEST['series_title']))
$seriesTitleName = encodeHTML($_REQUEST['series_title']);
else
$seriesTitleName = "";
if (isset($_REQUEST['abbrev_series_title']))
$abbrevSeriesTitleName = encodeHTML($_REQUEST['abbrev_series_title']);
else
$abbrevSeriesTitleName = "";
if (isset($_REQUEST['series_volume']))
$seriesVolumeNo = encodeHTML($_REQUEST['series_volume']);
else
$seriesVolumeNo = "";
if (isset($_REQUEST['series_issue']))
$seriesIssueNo = encodeHTML($_REQUEST['series_issue']);
else
$seriesIssueNo = "";
if (isset($_REQUEST['edition']))
$editionNo = encodeHTML($_REQUEST['edition']);
else
$editionNo = "";
if (isset($_REQUEST['issn']))
$issnName = encodeHTML($_REQUEST['issn']);
else
$issnName = "";
if (isset($_REQUEST['isbn']))
$isbnName = encodeHTML($_REQUEST['isbn']);
else
$isbnName = "";
$mediumName = "";
if (isset($_REQUEST['area']))
$areaName = encodeHTML($_REQUEST['area']);
else
$areaName = "";
$expeditionName = "";
if (isset($_REQUEST['conference']))
$conferenceName = encodeHTML($_REQUEST['conference']);
else
$conferenceName = "";
if (isset($_REQUEST['notes']))
$notesName = encodeHTML($_REQUEST['notes']);
else
$notesName = "";
$approvedRadio = "";
$locationName = $locationName; // supply some generic info: "(...will be filled in automatically)" [as defined at the top of this script]
$rawLocationName = "";
if (isset($_REQUEST['call_number']))
{
// if the data did originate from an import form -AND- (if the user isn't logged in -OR- any normal user is logged in (not the admin))...
if ($recordAction == "add" AND $mode == "import" AND ((!isset($loginEmail)) OR ((isset($loginEmail)) AND ($loginEmail != $adminLoginEmail))))
{
$callNumberName = "";
$callNumberNameUserOnly = encodeHTML($_REQUEST['call_number']); // for import, we assume that the contents of the call number field fully belong to the current user
}
else // if the data didn't originate from an import form or if the admin is logged in...
{
$callNumberName = encodeHTML($_REQUEST['call_number']);
$callNumberNameUserOnly = "";
}
}
else
{
$callNumberName = "";
$callNumberNameUserOnly = "";
}
$serialNo = $serialNo; // supply some generic info: "(not assigned yet)" [as defined at the top of this script]
if (isset($_REQUEST['type']))
$typeName = encodeHTML($_REQUEST['type']);
else
$typeName = "";
if (isset($_REQUEST['thesis']))
$thesisName = encodeHTML($_REQUEST['thesis']);
else
$thesisName = "";
if (isset($_REQUEST['marked']))
$markedRadio = encodeHTML($_REQUEST['marked']);
else
$markedRadio = "";
if (isset($_REQUEST['copy']))
$copyName = encodeHTML($_REQUEST['copy']);
else
$copyName = "";
if (isset($_REQUEST['selected']))
$selectedRadio = encodeHTML($_REQUEST['selected']);
else
$selectedRadio = "";
if (isset($_REQUEST['user_keys']))
$userKeysName = encodeHTML($_REQUEST['user_keys']);
else
$userKeysName = "";
if (isset($_REQUEST['user_notes']))
$userNotesName = encodeHTML($_REQUEST['user_notes']);
else
$userNotesName = "";
if (isset($_REQUEST['user_file']))
$userFileName = encodeHTML($_REQUEST['user_file']);
else
$userFileName = "";
if (isset($_REQUEST['user_groups']))
$userGroupsName = encodeHTML($_REQUEST['user_groups']);
else
$userGroupsName = "";
if (isset($_REQUEST['cite_key']))
$citeKeyName = encodeHTML($_REQUEST['cite_key']);
else
$citeKeyName = "";
if (isset($_REQUEST['related']))
$relatedName = encodeHTML($_REQUEST['related']);
else
$relatedName = "";
// NOTE: currently, we only allow for file URLs with full URL paths
//
// TODO: - ensure that there aren't any security issues
// - should we accept local file paths/names from the import data? if so, how should we handle them?
// - make sure that any recognized PDF files get renamed & filed according to the settings in 'initialize/ini.inc.php';
// in case of remote file URLs, this may mean downloading the remote PDF, and filing/renaming it according to preference
if (isset($_REQUEST['file']) AND preg_match("/^(https?|ftp|file):\/\//", $_REQUEST['file'])) // if the 'file' field contains a full URL (starting with "http://", "https://", "ftp://" or "file://")
$fileName = encodeHTML($_REQUEST['file']);
else
$fileName = "";
if (isset($_REQUEST['url']))
$urlName = encodeHTML($_REQUEST['url']);
else
$urlName = "";
if (isset($_REQUEST['doi']))
$doiName = encodeHTML($_REQUEST['doi']);
else
$doiName = "";
$contributionID = "";
$onlinePublication = "";
$onlineCitationName = "";
$createdDate = ""; // for INSERTs, 'created_...' and 'modified_...' variables will get fresh values in 'modify.php' anyhow
$createdTime = "";
$createdBy = "";
$modifiedDate = "";
$modifiedTime = "";
$modifiedBy = "";
$origRecord = "";
}
else // the user tried to add or edit a record but...
{
if (!empty($errors)) // ...there were some errors on submit. -> Re-load the data that were submitted by the user:
{
foreach($formVars as $varname => $value)
// remove slashes from parameter values if 'magic_quotes_gpc = On':
$formVars[$varname] = stripSlashesIfMagicQuotes($value); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php'
if (isset($formVars['authorName']))
$authorName = $formVars['authorName'];
else
$authorName = "";
if (isset($formVars['isEditorCheckBox'])) // the user did mark the "is Editor" checkbox
$isEditorCheckBox = $formVars['isEditorCheckBox'];
if (isset($formVars['titleName']))
$titleName = $formVars['titleName'];
else
$titleName = "";
if (isset($formVars['yearNo']))
$yearNo = $formVars['yearNo'];
else
$yearNo = "";
if (isset($formVars['publicationName']))
$publicationName = $formVars['publicationName'];
else
$publicationName = "";
if (isset($formVars['abbrevJournalName']))
$abbrevJournalName = $formVars['abbrevJournalName'];
else
$abbrevJournalName = "";
if (isset($formVars['volumeNo']))
$volumeNo = $formVars['volumeNo'];
else
$volumeNo = "";
if (isset($formVars['issueNo']))
$issueNo = $formVars['issueNo'];
else
$issueNo = "";
if (isset($formVars['pagesNo']))
$pagesNo = $formVars['pagesNo'];
else
$pagesNo = "";
if (isset($formVars['addressName']))
$addressName = $formVars['addressName'];
else
$addressName = "";
if (isset($formVars['corporateAuthorName']))
$corporateAuthorName = $formVars['corporateAuthorName'];
else
$corporateAuthorName = "";
if (isset($formVars['keywordsName']))
$keywordsName = $formVars['keywordsName'];
else
$keywordsName = "";
if (isset($formVars['abstractName']))
$abstractName = $formVars['abstractName'];
else
$abstractName = "";
if (isset($formVars['publisherName']))
$publisherName = $formVars['publisherName'];
else
$publisherName = "";
if (isset($formVars['placeName']))
$placeName = $formVars['placeName'];
else
$placeName = "";
if (isset($formVars['editorName']))
$editorName = $formVars['editorName'];
else
$editorName = "";
if (isset($formVars['languageName']))
$languageName = $formVars['languageName'];
else
$languageName = "";
if (isset($formVars['summaryLanguageName']))
$summaryLanguageName = $formVars['summaryLanguageName'];
else
$summaryLanguageName = "";
if (isset($formVars['origTitleName']))
$origTitleName = $formVars['origTitleName'];
else
$origTitleName = "";
if (isset($formVars['seriesEditorName']))
$seriesEditorName = $formVars['seriesEditorName'];
else
$seriesEditorName = "";
if (isset($formVars['seriesTitleName']))
$seriesTitleName = $formVars['seriesTitleName'];
else
$seriesTitleName = "";
if (isset($formVars['abbrevSeriesTitleName']))
$abbrevSeriesTitleName = $formVars['abbrevSeriesTitleName'];
else
$abbrevSeriesTitleName = "";
if (isset($formVars['seriesVolumeNo']))
$seriesVolumeNo = $formVars['seriesVolumeNo'];
else
$seriesVolumeNo = "";
if (isset($formVars['seriesIssueNo']))
$seriesIssueNo = $formVars['seriesIssueNo'];
else
$seriesIssueNo = "";
if (isset($formVars['editionNo']))
$editionNo = $formVars['editionNo'];
else
$editionNo = "";
if (isset($formVars['issnName']))
$issnName = $formVars['issnName'];
else
$issnName = "";
if (isset($formVars['isbnName']))
$isbnName = $formVars['isbnName'];
else
$isbnName = "";
if (isset($formVars['mediumName']))
$mediumName = $formVars['mediumName'];
else
$mediumName = "";
if (isset($formVars['areaName']))
$areaName = $formVars['areaName'];
else
$areaName = "";
if (isset($formVars['expeditionName']))
$expeditionName = $formVars['expeditionName'];
else
$expeditionName = "";
if (isset($formVars['conferenceName']))
$conferenceName = $formVars['conferenceName'];
else
$conferenceName = "";
if (isset($formVars['notesName']))
$notesName = $formVars['notesName'];
else
$notesName = "";
if (isset($formVars['approvedRadio']))
$approvedRadio = $formVars['approvedRadio'];
else
$approvedRadio = "";
if ($recordAction == "edit")
{
if (isset($formVars['locationName']))
{
$locationName = $formVars['locationName'];
$rawLocationName = $formVars['locationName'];
}
else
{
$locationName = "";
$rawLocationName = "";
}
}
else
{
$locationName = $locationName; // supply some generic info: "(...will be filled in automatically)" [as defined at the top of this script]
$rawLocationName = "";
}
if (isset($formVars['callNumberName']))
$callNumberName = $formVars['callNumberName'];
else
$callNumberName = "";
if (preg_match("/%40/", $callNumberName)) // if '$callNumberName' still contains URL encoded data... ('%40' is the URL encoded form of the character '@', see note below!)
$callNumberName = rawurldecode($callNumberName); // ...URL decode 'callNumberName' variable contents (it was URL encoded before incorporation into a hidden tag of the 'record' form to avoid any HTML syntax errors)
// NOTE: URL encoded data that are included within a *link* will get URL decoded automatically *before* extraction via '$_POST'!
// But, opposed to that, URL encoded data that are included within a form by means of a *hidden form tag* will NOT get URL decoded automatically! Then, URL decoding has to be done manually (as is done here)!
if (isset($formVars['callNumberNameUserOnly']))
$callNumberNameUserOnly = $formVars['callNumberNameUserOnly'];
else
$callNumberNameUserOnly = "";
if ($recordAction == "edit")
$serialNo = $formVars['serialNo'];
else
$serialNo = $serialNo; // supply some generic info: "(not assigned yet)" [as defined at the top of this script]
if (isset($formVars['typeName']))
$typeName = $formVars['typeName'];
else
$typeName = "";
if (isset($formVars['thesisName']))
$thesisName = $formVars['thesisName'];
else
$thesisName = "";
if (isset($formVars['markedRadio']))
$markedRadio = $formVars['markedRadio'];
else
$markedRadio = "";
if (isset($formVars['copyName']))
$copyName = $formVars['copyName'];
else
$copyName = "";
if (isset($formVars['selectedRadio']))
$selectedRadio = $formVars['selectedRadio'];
else
$selectedRadio = "";
if (isset($formVars['userKeysName']))
$userKeysName = $formVars['userKeysName'];
else
$userKeysName = "";
if (isset($formVars['userNotesName']))
$userNotesName = $formVars['userNotesName'];
else
$userNotesName = "";
if (isset($formVars['userFileName']))
$userFileName = $formVars['userFileName'];
else
$userFileName = "";
if (isset($formVars['userGroupsName']))
$userGroupsName = $formVars['userGroupsName'];
else
$userGroupsName = "";
if (isset($formVars['citeKeyName']))
$citeKeyName = $formVars['citeKeyName'];
else
$citeKeyName = "";
if (isset($formVars['relatedName']))
$relatedName = $formVars['relatedName'];
else
$relatedName = "";
if (isset($formVars['fileName']))
$fileName = $formVars['fileName'];