source: trunk/biblehal/biblehal-push @ 53

Last change on this file since 53 was 8, checked in by g7moreau, 12 years ago
  • Move biblehal folder in subfolder of trakata
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/usr/bin/perl
2#
3# gabriel 2010/06/03
4#
5# apt-get install libwww-mechanize-perl libwww-perl
6
7use strict;
8
9use WWW::Mechanize;
10use Data::Dumper;
11
12my $file_upload = $ARGV[0];
13die "Usage /usr/lib/biblehal/biblehal-push file.bib" if not -f $file_upload;
14
15
16my $config_file = '/etc/refbase.conf';
17my $connect_name = qx{ grep '\$adminLoginEmail =' $config_file | cut -f 2 -d "'" };
18my $connect_pass = qx{ grep '\$adminLoginPass ='  $config_file | cut -f 2 -d "'" };
19chomp($connect_name, $connect_pass);
20
21
22# Création du bot
23my $url = 'http://localhost/'; # refbase server
24my $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&eacute;es">Importer</a>
90
91suivre le lien
92
93
94--3
95
96form 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">&nbsp;</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">&nbsp;</td>
112        <td rowspan="2">&nbsp;</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">&nbsp;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">&nbsp;Only:&nbsp;&nbsp;<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>&nbsp;</td>
123        <td>&nbsp;</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
Note: See TracBrowser for help on using the repository browser.