Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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