Subversion Repositories eFlore/Applications.cel

Rev

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

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