1 | #!/usr/bin/perl |
---|
2 | # |
---|
3 | # gabriel 2010/06/03 |
---|
4 | # |
---|
5 | # apt-get install libwww-mechanize-perl libwww-perl |
---|
6 | |
---|
7 | use strict; |
---|
8 | |
---|
9 | use WWW::Mechanize; |
---|
10 | use Data::Dumper; |
---|
11 | |
---|
12 | my $file_upload = $ARGV[0]; |
---|
13 | die "Usage /usr/lib/biblehal/biblehal-push file.bib" if not -f $file_upload; |
---|
14 | |
---|
15 | |
---|
16 | my $config_file = '/etc/refbase.conf'; |
---|
17 | my $connect_name = qx{ grep '\$adminLoginEmail =' $config_file | cut -f 2 -d "'" }; |
---|
18 | my $connect_pass = qx{ grep '\$adminLoginPass =' $config_file | cut -f 2 -d "'" }; |
---|
19 | chomp($connect_name, $connect_pass); |
---|
20 | |
---|
21 | |
---|
22 | # Création du bot |
---|
23 | my $url = 'http://localhost/'; # refbase server |
---|
24 | my $bot = WWW::Mechanize->new; |
---|
25 | |
---|
26 | # Hop, c'est parti, premiere page |
---|
27 | $bot->get($url); |
---|
28 | |
---|
29 | |
---|
30 | #--1 |
---|
31 | # |
---|
32 | #form numero 2 |
---|
33 | # <form action="user_login.php" method="POST" name="login"> |
---|
34 | # <fieldset> |
---|
35 | # <legend>Login:</legend> |
---|
36 | # <input type="hidden" name="referer" value="index.php"> |
---|
37 | # <div id="loginUser"> |
---|
38 | # <div id="loginUserLabel"> |
---|
39 | # |
---|
40 | # <label for="loginEmail">Email:</label> |
---|
41 | # </div> |
---|
42 | # <div id="loginUserInput"> |
---|
43 | # <input type="text" id="loginEmail" name="loginEmail"> |
---|
44 | # </div> |
---|
45 | # </div> |
---|
46 | # <div id="loginPwd"> |
---|
47 | # <div id="loginPwdLabel"> |
---|
48 | # |
---|
49 | # <label for="loginPassword">Password:</label> |
---|
50 | # </div> |
---|
51 | # <div id="loginPwdInput"> |
---|
52 | # <input type="password" id="loginPassword" name="loginPassword"> |
---|
53 | # </div> |
---|
54 | # </div> |
---|
55 | # <div id="loginSubmit"> |
---|
56 | # <input type="submit" value="Login"> |
---|
57 | # |
---|
58 | # </div> |
---|
59 | # </fieldset> |
---|
60 | # </form> |
---|
61 | |
---|
62 | # Hop, seconde page, on choisis le second formulaire |
---|
63 | $bot->form_number(2); |
---|
64 | |
---|
65 | $bot->field('loginEmail', "$connect_name"); |
---|
66 | $bot->field('loginPassword', "$connect_pass"); |
---|
67 | |
---|
68 | $bot->submit; |
---|
69 | |
---|
70 | $bot->get('import.php'); |
---|
71 | |
---|
72 | |
---|
73 | $bot->form_number(2); |
---|
74 | |
---|
75 | $bot->field('uploadFile', "$file_upload"); |
---|
76 | |
---|
77 | $bot->submit; |
---|
78 | |
---|
79 | $bot->form_number(2); |
---|
80 | $bot->submit; |
---|
81 | |
---|
82 | #print $bot->content; |
---|
83 | |
---|
84 | |
---|
85 | __END__ |
---|
86 | |
---|
87 | --2 |
---|
88 | |
---|
89 | <a href="import.php" title="importer enregistrements dans la base de données">Importer</a> |
---|
90 | |
---|
91 | suivre le lien |
---|
92 | |
---|
93 | |
---|
94 | --3 |
---|
95 | |
---|
96 | form numero 2 sur 3 |
---|
97 | |
---|
98 | <form enctype="multipart/form-data" action="import_modify.php" method="POST"> |
---|
99 | <input type="hidden" name="formType" value="import"> |
---|
100 | <input type="hidden" name="submit" value="Import"> |
---|
101 | <input type="hidden" name="showLinks" value="1"> |
---|
102 | <input type="hidden" name="showSource" value="1"> |
---|
103 | <table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the main import form"> |
---|
104 | <tr> |
---|
105 | <td width="94" valign="top"><b>Records:</b></td> |
---|
106 | |
---|
107 | <td width="10"> </td> |
---|
108 | <td colspan="3"><textarea name="sourceText" rows="6" cols="63" title="paste your records here"></textarea></td> |
---|
109 | </tr> |
---|
110 | <tr> |
---|
111 | <td rowspan="2"> </td> |
---|
112 | <td rowspan="2"> </td> |
---|
113 | <td width="215" valign="top" rowspan="2"><input type="file" name="uploadFile" size="17" title="??import records from a file"></td> |
---|
114 | <td width="98" valign="top" rowspan="2">Import records:</td> |
---|
115 | <td valign="top"><input type="radio" name="importRecordsRadio" value="all" checked title="choose 'All' if you want to import all records at once"> All</td> |
---|
116 | |
---|
117 | </tr> |
---|
118 | <tr> |
---|
119 | <td valign="top"><input type="radio" name="importRecordsRadio" value="only" title="choose 'Only' if you just want to import particular records"> Only: <input type="text" name="importRecords" value="1" size="5" title="enter record number(s): e.g. '1-5 7' imports the first five and the seventh"></td> |
---|
120 | </tr> |
---|
121 | <tr> |
---|
122 | <td> </td> |
---|
123 | <td> </td> |
---|
124 | <td colspan="3"> |
---|
125 | <input type="submit" name="submit" value="Import" title="press this button to import the given source data"> |
---|
126 | </td> |
---|
127 | |
---|
128 | </tr> |
---|
129 | </table> |
---|
130 | </form> |
---|
131 | |
---|
132 | --4 |
---|
133 | |
---|