Subversion Repositories eFlore/Applications.cel

Rev

Rev 1773 | Rev 1914 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1768 raphael 1
<?php
2
 
1773 raphael 3
define('DEFAULT_DOMAIN', 'http://cel');
4
define('DEFAULT_USER', 22506);
5
 
1768 raphael 6
$options = getopt("hiou:d:e:p:FU:P:",array("help", "images", "obs", "user:", "domain:", "email:", "pass:", "flush", "upload:", "phpsessid"));
1773 raphael 7
if(isset($options['h']) || isset($options['help'])) die(__help());
1768 raphael 8
 
1773 raphael 9
 
10
define('USER', isset($options['u']) ? $options['u'] : (isset($options['user']) ? $options['user'] : DEFAULT_USER));
11
define('DOMAIN', isset($options['d']) ? $options['d'] : (isset($options['domain']) ? $options['domain'] : DEFAULT_DOMAIN));
1768 raphael 12
define('EMAIL', isset($options['e']) ? $options['e'] : (isset($options['email']) ? $options['email'] : NULL));
13
define('PASS', isset($options['p']) ? $options['p'] : (isset($options['pass']) ? $options['pass'] : NULL));
14
define('COOKIE', isset($options['P']) ? $options['P'] : (isset($options['phpsessid']) ? $options['phpsessid'] : NULL));
15
 
16
// API::auth() define()'s COOKIE
17
require_once('api.php');
18
 
19
if(isset($options['o']) || isset($options['obs']) || isset($options['F']) || isset($options['flush'])) {
20
	cel_delete_all_obs();
21
}
22
 
23
if(isset($options['i']) || isset($options['images']) || isset($options['F']) || isset($options['flush'])) {
24
	cel_delete_all_images();
25
}
26
 
27
$upload = isset($options['U']) ? $options['U'] : (isset($options['upload']) ? $options['upload'] : NULL);
28
if($upload) cel_upload_image($upload);
29
 
30
if(! COOKIE) { if(!auth()) die('no auth'); }
31
 
32
 
33
// $csv = genCSV(array('ordre' => 1, 'Date' => '23/06/1991', 'rien' => 'rien'));
34
var_dump(getCSV_line(export(), 1));
1773 raphael 35
 
36
 
37
 
38
 
39
 
40
 
41
 
42
 
43
 
44
 
45
 
46
 
47
 
48
 
49
 
50
function __help() {
51
	$m = sprintf(
52
<<<EOF
53
%1\$s -i|--images -o|--obs -F|--flush
54
    Supprime les images ou les observations, ou les deux, de l'utilisateur donné sur le CEL donné.
55
 
56
Options:
57
%1\$s [-u|--user = %3\$d] [-d|--domain = %2\$s] [-e|--email] [-p|--pass mot de passe] [-P|--phpsessid PHPSESSID]
58
    La priorité est donnée à -P sur le couple (-e , -p) pour l'authentification, eg:
59
    $ sqlite3 .mozilla/firefox/*.default/cookies.sqlite<<<"SELECT * FROM moz_cookies WHERE baseDomain = 'cel' AND name = 'PHPSESSID';"
60
 
61
%1\$s -u|--upload <file>
62
    Upload le fichier "file".
63
EOF
64
, // */
65
basename(__FILE__),
66
DEFAULT_DOMAIN,
67
DEFAULT_USER);
68
	die($m);
69
}