Subversion Repositories eFlore/Applications.cel

Rev

Rev 1768 | Blame | Last modification | View Log | RSS feed

<?php

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

$options = getopt("hiou:d:e:p:FU:P:",array("help", "images", "obs", "user:", "domain:", "email:", "pass:", "flush", "upload:", "phpsessid"));
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('COOKIE', isset($options['P']) ? $options['P'] : (isset($options['phpsessid']) ? $options['phpsessid'] : NULL));

// 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(! 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);
}