Пример #1
0
function compta_setdefault()
{
    $usr = new Modele('users');
    $usr->fetch($_SESSION['user']['user_id']);
    if ($_GET['account'] == 0) {
        $usr->user_compta = 0;
        $_SESSION['user']['user_compta'] = 0;
        redirect("compta", "index", array('hsuccess' => 1));
    }
    $mdlAcc = new Modele('user_accounts');
    $mdlAcc->fetch($_GET['account']);
    if ($mdlAcc->raw_ua_user == $_SESSION['user']['user_id']) {
        $usr->user_compta = $mdlAcc->getKey();
        $_SESSION['user']['user_compta'] = $mdlAcc->getKey();
        redirect("compta", "index", array('hsuccess' => 1));
    }
    redirect("compta", "index", array('hsuccess' => 0));
}
Пример #2
0
function bocal_update()
{
    global $srcdir;
    include $srcdir . '/libs/bocal.php';
    $mdl = new Modele('event_bocal');
    $mdl->find();
    $boc = new Bocal();
    while ($mdl->next()) {
        $boc->getTicket($mdl->eb_ticket);
        $boc->updateDB($mdl->getKey());
    }
    echo "ok";
}
Пример #3
0
function cards_delbundle()
{
    $bdl = new Modele('cardbundle');
    $bdl->fetch($_GET['bundle']);
    $crd = new Modele('card');
    $crd->find(array('card_bundle' => $bdl->getKey()));
    while ($crd->next()) {
        $crd->card_bundle = null;
        $crd->card_status = 'WAIT';
    }
    $bdl->delete();
    redirect('cards');
}
Пример #4
0
function api_token()
{
    //    $_POST['grant_type'];
    //    $_POST['code'];
    //    $_POST['redirect_uri'];
    //    $_POST['client_id'];
    //    $_POST['client_secret'];
    //On ne fait que des tokens d'auth
    if ($_REQUEST['grant_type'] != 'authorization_code') {
        return _api_error('grant_type', 'Only authorization_code is supported');
    }
    //Recherche du client
    $cli = new Modele('api_clients');
    $cli->find(array('ac_client' => $_REQUEST['client_id'], 'ac_secret' => $_REQUEST['client_secret']));
    if (!$cli->next()) {
        return _api_error('unauthorized_client', 'API client denied.');
    }
    //Verif callback client
    $allowed_callbaks = explode("\n", $cli->ac_callback);
    foreach ($allowed_callbaks as &$callback) {
        $callback = trim($callback, " \t\n\r\v/");
    }
    if ($_REQUEST['redirect_uri'] == '' || !in_array($_REQUEST['redirect_uri'], $allowed_callbaks)) {
        return _api_error('invalid_request_uri', 'Callback not registred 1 :' . $_REQUEST['redirect_uri']);
        //Force l'arrêt
    }
    //Recherche du token
    $tok = new Modele('api_tokens');
    $tok->find(array('at_client' => $cli->getKey(), 'at_code' => $_REQUEST['code'], 'at_type' => 'AUTH'));
    if (!$tok->next()) {
        return _api_error('invalid_grant', 'API token not found.');
    }
    if ($tok->at_expire < time()) {
        return _api_error('invalid_grant', 'API token too old.');
    }
    if ($tok->at_uri != '' && (!isset($_REQUEST['redirect_uri']) || $tok->at_uri != $_REQUEST['redirect_uri'])) {
        return _api_error('invalid_request', 'Request URI invalid');
    }
    $update = array('at_type' => 'ACCESS', 'at_code' => md5(uniqid('', true)), 'at_start' => time(), 'at_expire' => time() + 3600);
    if (!$tok->modFrom($update)) {
        return _api_error('server_error', 'API token update.');
    }
    //Reponse
    $config = _api_config();
    $header = array('alg' => 'RS256', 'typ' => 'JWT');
    $claims = array('iss' => $config['issuer'], 'sub' => $update['at_code'], 'aud' => $cli->ac_client, 'exp' => $update['at_expire'], 'iat' => $update['at_start']);
    if ($tok->at_nonce != '') {
        $claims['nonce'] = $tok->at_nonce;
    }
    $payload = base64url_encode(json_encode($header)) . '.' . base64url_encode(json_encode($claims));
    $token = array('id_token' => $payload . '.' . base64url_encode(_api_sign($payload)), 'access_token' => $update['at_code'], 'token_type' => 'bearer', 'expires_in' => 3600);
    if ($tok->at_scope != '') {
        $token['scope'] = $tok->at_scope;
    }
    echo json_encode($token);
    quit();
}
Пример #5
0
function user_setcompta()
{
    $usr = new Modele('users');
    $usr->fetch($_GET['user']);
    if ($_GET['account'] == 0) {
        $usr->user_compta = 0;
        redirect("user", "view", array('hsuccess' => 1, 'user' => $usr->getKey()));
    }
    $mdlAcc = new Modele('user_accounts');
    $mdlAcc->fetch($_GET['account']);
    if ($mdlAcc->raw_ua_user == $usr->getKey()) {
        $usr->user_compta = $mdlAcc->getKey();
        redirect("user", "view", array('hsuccess' => 1, 'user' => $usr->getKey()));
    }
    redirect("user", "view", array('hsuccess' => 0, 'user' => $usr->getKey()));
}
Пример #6
0
function section_addpoints()
{
    global $tpl, $pdo;
    $section = new Modele('sections');
    $section->fetch($_REQUEST['section']);
    $tpl->assign('section', $section);
    $queryFields = array('part_duration', 'part_title', 'part_justification');
    $mdl = new Modele('participations');
    $tpl->assign('form', $mdl->edit($queryFields));
    if (isset($_POST['edit'])) {
        $data = array('part_section' => $section->section_id, 'part_attribution_date' => date('Y-m-d'), 'part_status' => 'SUBMITTED');
        foreach ($queryFields as $field) {
            $data[$field] = $_POST[$field];
        }
        if (!$mdl->addFrom($data)) {
            redirect('section', 'details', array('section' => $section->section_id, 'hsuccess' => '0'));
        }
        $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN users ON user_id = us_user WHERE us_section = ? ORDER BY user_name');
        $sql->bindValue(1, $section->section_id);
        $sql->execute();
        $mdlMark = new Modele('marks');
        $dataMark = array('mark_participation' => $mdl->getKey());
        while ($user = $sql->fetch()) {
            if (in_array($user['user_id'], $_POST['staffs'])) {
                $dataMark['mark_user'] = $user['user_id'];
                $dataMark['mark_period'] = $_POST['type-' . $user['user_type']];
                $mdlMark->addFrom($dataMark);
            }
        }
        redirect('section', 'details', array('section' => $section->section_id, 'hsuccess' => '1'));
    }
    $types = new Modele('user_types');
    $types->find();
    while ($type = $types->next()) {
        $periods = $pdo->prepare('SELECT * FROM periods WHERE period_start < NOW() AND period_end > NOW() AND period_type = ? AND period_state = "ACTIVE"');
        $periods->bindValue(1, $types->ut_id);
        $periods->execute();
        $repPeriods = array();
        while ($period = $periods->fetch()) {
            $repPeriods[] = $period;
        }
        $tpl->append('types', array('id' => $types->ut_id, 'name' => $types->ut_name, 'periods' => $repPeriods));
    }
    $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN users ON user_id = us_user WHERE us_section = ? ORDER BY user_name');
    $sql->bindValue(1, $section->section_id);
    $sql->execute();
    while ($user = $sql->fetch()) {
        $tpl->append('staffs', $user);
    }
    display();
}
Пример #7
0
function ml_execUpdate()
{
    $section = new Modele('sections');
    $section->find('section_ml != ""');
    $api = new GoogleApi();
    while ($section->next()) {
        $toAdd = array();
        $toDelete = array();
        $Lmembers = new Modele('user_sections');
        $Lmembers->find(array('us_section' => $section->getKey(), 'us_type' => 'manager'));
        while ($Lmembers->next()) {
            $toAdd[] = strtolower($Lmembers->us_user->user_email);
        }
        $reelMembers = $api->getGroupMembers($section->section_ml);
        if (isset($reelMembers->members)) {
            foreach ($reelMembers->members as $member) {
                $key = array_keys($toAdd, strtolower($member->email));
                if (strpos($member->email, 'save_') !== 0) {
                    //Skip sauvegarde
                    if ($member->type == "GROUP") {
                        continue;
                    } elseif (count($key) == 0) {
                        $toDelete[] = strtolower($member->email);
                    } else {
                        unset($toAdd[$key[0]]);
                    }
                }
            }
        }
        foreach ($toAdd as $mail) {
            $api->addGroupMember($section->section_ml, $mail);
        }
        foreach ($toDelete as $mail) {
            $api->delGroupMember($section->section_ml, $mail);
        }
    }
    redirect('ml', 'autoUpdate');
}
Пример #8
0
function wifi_add()
{
    global $tpl;
    if (isset($_POST['save'])) {
        $f = fopen($_FILES['file']['tmp_name'], 'r');
        $tokens = array();
        $roll = null;
        while (!feof($f)) {
            $l = fgets($f);
            if (preg_match('`# Voucher Tickets [0-9]*..[0-9]* for Roll ([0-9]*)`', $l, $pmatch)) {
                $roll = $pmatch[1];
            } elseif ($l[0] != "#") {
                $token = trim($l, "\t\n\r\v\" ");
                if (strlen($token)) {
                    $tokens[] = $token;
                }
            }
        }
        fclose($f);
        unlink($_FILES['file']['tmp_name']);
        if (count($tokens) == 0 || $roll == null) {
            echo "Erreur de parsing";
            $tpl->assign('hsuccess', false);
        } else {
            $mdl = new Modele('wifi_tokenGroup');
            if ($mdl->addFrom(array('wtg_roll' => $roll, 'wtg_duration' => $_POST['duration'], 'wtg_date' => date('Y-m-d')))) {
                $id = $mdl->getKey();
                $tkn = new Modele('wifi_tokens');
                foreach ($tokens as $token) {
                    $tkn->addFrom(array('wt_token' => $token, 'wt_group' => $id));
                }
                $tpl->assign('hsuccess', true);
            } else {
                echo 'Erreur insertion WTG.';
                $tpl->assign('hsuccess', false);
            }
        }
    }
    display();
}
Пример #9
0
function admin_note_delperiod()
{
    $prd = new Modele('periods', $_REQUEST['id']);
    $marks = new Modele('marks');
    $marks->find(array('mark_period' => $prd->getKey()));
    while ($marks->next()) {
        $marks->delete();
    }
    $prd->delete();
    redirect('admin_note', 'periods', array('hsuccess' => 1));
}
Пример #10
0
function trip_opt_add()
{
    global $tpl;
    $mod = new Modele('trip_options');
    $mod->fetch($_GET['option']);
    $mod->assignTemplate('option');
    $mdl = $mod->topt_trip;
    $mdl->assignTemplate('trip');
    $opt = new Modele('trip_option_options');
    $tpl->assign('form', $opt->edit(array('too_value', 'too_price')));
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $data = array_merge($_POST, array('too_option' => $mod->getKey()));
        if ($opt->addFrom($data)) {
            redirect('trip', 'opt_list', array('option' => $mod->getKey(), 'hsuccess' => 1));
        }
        $tpl->assign('hsuccess', false);
    }
    display();
}
Пример #11
0
function event_bocal_view()
{
    global $tpl, $pdo, $srcdir;
    $sql = $pdo->prepare('SELECT * FROM events LEFT JOIN users ON event_owner = user_id LEFT JOIN sections ON section_id = event_section WHERE event_id = ?');
    $sql->bindValue(1, $_GET['event']);
    $sql->execute();
    $event = $sql->fetch();
    if (!$event) {
        modexec('syscore', 'notfound');
    }
    $tpl->assign('event', $event);
    $mdl = new Modele('event_bocal');
    $mdl->find(array('eb_id' => $_GET['ticket'], 'eb_event' => $event['event_id']));
    if (!$mdl->next()) {
        modexec('syscore', 'notfound');
    }
    include_once $srcdir . '/libs/bocal.php';
    $bocal = new Bocal();
    if (!$bocal->getTicket($mdl->eb_ticket)) {
        modexec('syscore', 'notfound');
    }
    $bocal->updateDB($mdl->getKey());
    $tpl->assign('ticket', $bocal);
    display();
}
Пример #12
0
function tripusr_step4()
{
    global $tpl;
    $ufile = _tripusr_load();
    if ($ufile->tu_step != 4) {
        redirect('tripusr', 'continue', array('file' => $ufile->getKey()));
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if (isset($_POST["next"])) {
            $bill = new Modele('trip_types');
            $bill->fetch($_POST['ticket']);
            switch ($bill->raw_tt_restriction) {
                case 'ALL':
                    $ufile->tu_type = $bill->getKey();
                    $ufile->tu_price = $bill->tt_price;
                    $ufile->tu_step = 5;
                    redirect('tripusr', 'step5', array('file' => $ufile->getKey()));
                    break;
                case 'USER':
                    $ufile->tu_type = $bill->getKey();
                    if (aclFromText($_SESSION['user']['user_role']) >= ACL_USER) {
                        $ufile->tu_price = $bill->tt_price;
                        $ufile->tu_step = 5;
                        redirect('tripusr', 'step5', array('file' => $ufile->getKey()));
                    }
                    break;
                default:
                    echo 'ERROR: not implemented';
                    quit();
                    break;
            }
        }
        /* else {
           $questions = new Modele('trip_options');
           $questions->find(array('topt_trip' => $ufile->raw_tu_trip));
           // Pas de complements, go back etape 2
           if ($questions->count() == 0) {
           $ufile->tu_step = 2;
           redirect('tripusr', 'step2', array('file' => $ufile->getKey()));
           } else {
           $ufile->tu_step = 3;
           redirect('tripusr', 'step3', array('file' => $ufile->getKey()));
           }
           } */
    }
    $tickets = new Modele('trip_types');
    $tickets->find(array('tt_trip' => $ufile->raw_tu_trip));
    $tickets->appendTemplate('tickets');
    display();
}
Пример #13
-1
function index_print()
{
    global $root, $srcdir, $tmpdir;
    include_once $srcdir . DS . 'libs' . DS . 'fpdf.php';
    include_once $srcdir . DS . 'libs' . DS . 'barcode.php';
    if (!isset($_POST['mandate'])) {
        $_POST['mandate'] = 1;
    }
    if (!isset($_POST['subscription'])) {
        $_POST['subscription'] = 1;
    }
    $mdt = new Modele('mandate');
    $mdt->fetch($_POST['mandate']);
    $sub = new Modele('subscription');
    $sub->fetch($_POST['subscription']);
    $usr = new Modele('users');
    $usr->fetch($_SESSION['user']['user_id']);
    $sublist = new Modele('subscription');
    //$sublist->find(array('subscription_mandate' => $mdt->mandate_id));
    $sublist->find();
    if (new DateTime($mdt->mandate_start) > new DateTime() || new DateTime($mdt->mandate_end) < new DateTime()) {
        modexec('syscore', 'moderror');
    }
    ob_start();
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetXY(18, 12);
    $pdf->SetFont('Arial', '', 30);
    $pdf->Cell(180, 10, 'EPITANIME', 0, 0, 'C');
    $pdf->SetFont('Arial', '', 10);
    $pdf->SetXY(18, 21);
    $pdf->Cell(180, 5, 'FEUILLE DE RENSEIGNEMENTS ' . uc($mdt->mandate_label), 0, 0, 'C');
    $pdf->SetXY(18, 26);
    $pdf->Cell(180, 5, 'Veuillez remplir lisiblement en lettres capitales', 0, 0, 'C');
    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetXY(18, 35);
    $pdf->Cell(180, 5, 'Informations essentielles :', 0, 0, '');
    $pdf->SetXY(18, 40);
    $pdf->Cell(50, 5, 'Pseudo', 1, 0, '');
    $pdf->SetXY(18, 45);
    $pdf->Cell(50, 5, 'Nom', 1, 0, '');
    $pdf->SetXY(18, 50);
    $pdf->Cell(50, 5, uc('Prénom'), 1, 0, '');
    $pdf->SetXY(18, 55);
    $pdf->Cell(50, 5, 'Adresse', 1, 0, '');
    $pdf->SetXY(18, 60);
    $pdf->Cell(50, 5, 'Code postal', 1, 0, '');
    $pdf->SetXY(18, 65);
    $pdf->Cell(50, 5, 'Ville', 1, 0, '');
    $pdf->SetXY(18, 70);
    $pdf->Cell(50, 5, 'Sexe', 1, 0, '');
    $pdf->SetXY(18, 75);
    $pdf->Cell(50, 5, 'Date de naissance', 1, 0, '');
    $pdf->SetXY(18, 80);
    $pdf->Cell(50, 5, uc('Téléphone'), 1, 0, '');
    $pdf->SetXY(18, 85);
    $pdf->Cell(50, 5, 'Courriel', 1, 0, '');
    $pdf->SetXY(18, 95);
    $pdf->Cell(50, 5, uc('Réservé aux étudiants IONIS'), 0, 0, '');
    $pdf->SetXY(18, 100);
    $pdf->Cell(50, 5, 'Login', 1, 0, '');
    $pdf->SetXY(18, 105);
    $pdf->Cell(50, 5, 'Ecole', 1, 0, '');
    $pdf->SetXY(18, 110);
    $pdf->Cell(50, 5, 'Promotion', 1, 0, '');
    $pdf->SetXY(18, 120);
    $pdf->Cell(50, 5, uc('Réservé aux membres prenant l\'inscription FFG (fédération française de GO)'), 0, 0, '');
    $pdf->SetXY(18, 125);
    $pdf->Cell(50, 5, uc('Nationalité'), 1, 0, '');
    $pdf->SetXY(18, 130);
    $pdf->Cell(50, 5, 'Niveau', 1, 0, '');
    $pdf->SetXY(18, 135);
    $pdf->Cell(50, 5, 'Pseudo FFG', 1, 0, '');
    $pdf->SetFont('Arial', '', 12);
    $pdf->SetXY(18, 222);
    $pdf->Cell(160, 5, uc('Reçu par ______________________ le ___/___/20___ , accompagné de la cotisation choisie.'), 0, 0, '');
    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetXY(38, 230);
    $pdf->Cell(50, 5, 'Signature du membre', 1, 0, '');
    $pdf->Rect(38, 235, 50, 20);
    $pdf->SetXY(130, 230);
    $pdf->Cell(50, 5, uc('Signature du récepteur'), 1, 0, '');
    $pdf->Rect(130, 235, 50, 20);
    $pdf->SetFont('Arial', '', 8);
    $pdf->SetXY(18, 260);
    $pdf->MultiCell(180, 3, uc('Les informations recueillies sont nécessaires pour votre adhésion. Elles font l’objet d’un traitement informatique et sont destinées au secrétariat de l’association. En application de l’article 34 de la loi du 6 janvier 1978, vous bénéficiez d’un droit d’accès et de rectification aux informations qui vous concernent. Si vous souhaitez exercer ce droit et obtenir communication des informations vous concernant, veuillez vous adresser au secrétariat de l’association.'));
    $pdf->SetFont('Arial', '', 10);
    $pdf->SetXY(68, 40);
    $pdf->Cell(130, 5, uc($usr->user_name), 1, 0, '');
    $pdf->SetXY(68, 45);
    $pdf->Cell(130, 5, uc($usr->user_lastname), 1, 0, '');
    $pdf->SetXY(68, 50);
    $pdf->Cell(130, 5, uc($usr->user_firstname), 1, 0, '');
    $pdf->SetXY(68, 55);
    $pdf->Cell(130, 5, uc($usr->user_address), 1, 0, '');
    $pdf->SetXY(68, 60);
    $pdf->Cell(130, 5, uc($usr->user_cp), 1, 0, '');
    $pdf->SetXY(68, 65);
    $pdf->Cell(130, 5, uc($usr->user_town), 1, 0, '');
    $pdf->SetXY(68, 70);
    $pdf->Cell(130, 5, uc($usr->user_sexe), 1, 0, '');
    $pdf->SetXY(68, 75);
    $pdf->Cell(130, 5, uc($usr->user_born), 1, 0, '');
    $pdf->SetXY(68, 80);
    $pdf->Cell(130, 5, uc($usr->user_phone), 1, 0, '');
    $pdf->SetXY(68, 85);
    $pdf->Cell(130, 5, uc($usr->user_email), 1, 0, '');
    $pdf->SetXY(68, 100);
    $pdf->Cell(130, 5, uc($usr->user_login), 1, 0, '');
    $pdf->SetXY(68, 105);
    $pdf->Cell(130, 5, uc($usr->user_type->ut_name), 1, 0, '');
    $pdf->SetXY(68, 110);
    $pdf->Cell(130, 5, uc($usr->user_promo), 1, 0, '');
    $pdf->SetXY(68, 125);
    $pdf->Cell(130, 5, '', 1, 0, '');
    $pdf->SetXY(68, 130);
    $pdf->Cell(130, 5, '', 1, 0, '');
    $pdf->SetXY(68, 135);
    $pdf->Cell(130, 5, '', 1, 0, '');
    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetXY(18, 145);
    $pdf->Cell(50, 5, uc('Cotisation'), 0, 0, '');
    $cb = '9' . str_pad($mdt->getKey(), 4, '0', STR_PAD_LEFT) . str_pad($usr->getKey(), 7, '0', STR_PAD_LEFT);
    $cbfile = tempnam($tmpdir, 'cb');
    imagebarcode($cbfile, $cb, 200, 40, 2);
    $pdf->Image($cbfile, 10, 10, 30, 0, 'PNG');
    unlink($cbfile);
    $pdf->SetFont('Arial', 'I', 8);
    $pdf->SetXY(185, 10);
    $pdf->Cell(10, 5, $usr->getKey(), 0, 0, 'R');
    $pos = -1;
    $pdf->SetFont('Arial', '', 10);
    while ($c = $sublist->next()) {
        $pos++;
        $x = 25 + $pos % 2 * 90;
        $y = 150 + 5 * floor($pos / 2);
        $pdf->SetXY($x, $y);
        $pdf->Cell(60, 5, uc($c['subscription_label']), 1, 0, '');
        $pdf->Cell(15, 5, number_format($c['subscription_price'], 2, ',', '') . ' ' . chr(128), 1, 0, '');
        $pdf->Rect($x + 75, $y, 5, 5);
        if ($c['subscription_id'] == $sub->subscription_id) {
            $pdf->SetFont('Arial', 'B', 12);
            $pdf->Cell(5, 5, 'X', 0, 0, 'C');
            $pdf->SetFont('Arial', '', 10);
        }
    }
    if (ob_get_flush() == '') {
        $pdf->Output('inscription.pdf', 'I');
    }
    quit();
}