Subversion Repositories eFlore/Applications.cel

Rev

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

#!/usr/bin/env php
<?php

define('DEFAULT_DOMAIN', 'http://cel');
define('DEFAULT_USER', 22506);

$options = getopt("hiou:d:e:p:FU:P:D",array("help", "images", "obs", "user:", "domain:", "email:", "pass:", "flush", "upload:", "phpsessid", "debug"));
if(isset($options['h']) || isset($options['help'])) die(__help());


define('USER', isset($options['u']) ? $options['u'] : (isset($options['user']) ? $options['user'] : DEFAULT_USER));
define('DOMAIN', isset($options['d']) ? $options['d'] : (isset($options['domain']) ? $options['domain'] : DEFAULT_DOMAIN));
define('EMAIL', isset($options['e']) ? $options['e'] : (isset($options['email']) ? $options['email'] : NULL));
define('PASS', isset($options['p']) ? $options['p'] : (isset($options['pass']) ? $options['pass'] : NULL));
define('DEBUG', isset($options['D']) ? 1 : (isset($options['debug']) ? 1 : 0));

if (isset($options['P'])) define('COOKIE', $options['P']);
elseif (isset($options['phpsessid'])) define('COOKIE', $options['phpsessid']);

// API::auth() define()'s COOKIE
require_once('api.php');

if(isset($options['o']) || isset($options['obs']) || isset($options['F']) || isset($options['flush'])) {
        cel_delete_all_obs();
}

if(isset($options['i']) || isset($options['images']) || isset($options['F']) || isset($options['flush'])) {
        cel_delete_all_images();
}

$upload = isset($options['U']) ? $options['U'] : (isset($options['upload']) ? $options['upload'] : NULL);
if($upload) cel_upload_image($upload);

if(! defined('COOKIE')) { if(!auth()) die('no auth'); }


// $csv = genCSV(array('ordre' => 1, 'Date' => '23/06/1991', 'rien' => 'rien'));
var_dump(getCSV_line(export(), 1));















function __help() {
        $m = sprintf(
<<<EOF
%1\$s -i|--images -o|--obs -F|--flush
    Supprime les images ou les observations, ou les deux, de l'utilisateur donné sur le CEL donné.

Options:
%1\$s [-u|--user = %3\$d] [-d|--domain = %2\$s] [-e|--email] [-p|--pass mot de passe] [-P|--phpsessid PHPSESSID]
    La priorité est donnée à -P sur le couple (-e , -p) pour l'authentification, eg:
    $ sqlite3 .mozilla/firefox/*.default/cookies.sqlite<<<"SELECT * FROM moz_cookies WHERE baseDomain = 'cel' AND name = 'PHPSESSID';"

%1\$s -U|--upload <file>
    Upload le fichier "file".

EOF
, // */
basename(__FILE__),
DEFAULT_DOMAIN,
DEFAULT_USER);
        die($m);
}