Пример #1
0
function _wifi_getToken()
{
    global $pdo;
    if (isset($_SESSION['user']) && $_SESSION['user']) {
        $alreadyToken = $pdo->prepare('SELECT * FROM wifi_tokens LEFT JOIN wifi_tokenGroup ON wt_group = wtg_id WHERE wt_assign = ? AND wt_date + INTERVAL wtg_duration MINUTE > NOW()');
        $alreadyToken->bindValue(1, $_SESSION['user']['user_id']);
        $alreadyToken->execute();
        if ($token = $alreadyToken->fetch()) {
            return $token['wt_token'];
        } else {
            $countStmt = $pdo->query('SELECT COUNT(*) FROM wifi_tokens WHERE wt_assign IS NULL');
            $countRslt = $countStmt->fetch();
            $tokenStmt = $pdo->prepare('SELECT * FROM wifi_tokens WHERE wt_assign IS NULL LIMIT 10, 1');
            //$tokenStmt->bindValue(1, rand(0, $countRslt[0] - 1));
            $tokenStmt->execute();
            $token = $tokenStmt->fetch();
            if ($token != null) {
                $mdl = new Modele('wifi_tokens');
                $mdl->fetch($token['wt_id']);
                $mdl->modFrom(array('wt_assign' => $_SESSION['user']['user_id'], 'wt_date' => date('Y-m-d H:i:s')), false);
                return $mdl->wt_token;
            } else {
                echo 'aucun tocken';
                return false;
                //Plus aucun token.
            }
        }
    } else {
        echo 'not logged';
        return false;
    }
}
Пример #2
0
function ftp_edit()
{
    global $tpl;
    $account = new Modele('ftp_users');
    $account->fetch($_GET['account']);
    $tpl->assign('account', $account);
    if (!hasAcl(ACL_SUPERUSER, 'ftp', 'index') && (!isset($_SESSION['user']['sections'][$account->raw_fu_section]) || $_SESSION['user']['sections'][$account->raw_fu_section]['us_type'] != 'manager')) {
        $tpl->assign('hsuccess', false);
        modexec('ftp');
    } else {
        if (isset($_POST['password'])) {
            if (strlen($_POST['password']) < 8) {
                $tpl->assign('badpass', 'Le mot de passe est trop court.');
                display();
            } else {
                $account->fu_pass = $_POST['password'];
                $usr = escapeshellarg($account->fu_user);
                $pwd = escapeshellarg($_POST['password']);
                _ftp_exec("sudo /opt/scripts/passwduser.sh {$usr} {$pwd}");
                $tpl->assign('hsuccess', true);
                modexec('ftp');
            }
        } else {
            display();
        }
    }
}
Пример #3
0
function bulletin_viewbulletin()
{
    global $pdo, $root;
    $mdl = new Modele("bulletin_user");
    $mdl->fetch($_GET['id']);
    require $root . 'libs' . DS . 'bulletins' . DS . $mdl->bu_period->period_generator . DS . 'bulletin.php';
    bulletin_view_user($_GET['id']);
    quit();
}
Пример #4
0
function developer_edit()
{
    $mdl = new Modele('api_clients');
    $mdl->fetch($_REQUEST['appli']);
    if (isset($_POST['callback'])) {
        $mdl->ac_callback = $_POST['callback'];
        redirect('developer', 'view', array('appli' => $_REQUEST['appli'], 'hsuccess' => '1'));
    }
    $mdl->assignTemplate('cli');
    display();
}
Пример #5
0
function note_viewp()
{
    global $tpl;
    $period = new Modele('periods');
    $period->fetch($_REQUEST['period']);
    $tpl->assign('period', $period);
    $mdl = new Modele('marks');
    $mdl->find(array('mark_user' => $_SESSION['user']['user_id'], 'mark_period' => $period->getKey()));
    while ($mdl->next()) {
        $tpl->append('marks', new Modele($mdl));
    }
    display();
}
Пример #6
0
function _tripadm_load()
{
    $ufile = new Modele('trip_userfiles');
    try {
        $ufile->fetch($_GET['file']);
    } catch (SQLFetchNotFound $e) {
        redirect('syscore', 'invcall');
    }
    //    if ($ufile->raw_tu_user != $_SESSION['user']['user_id']) {
    //        redirect('syscore', 'forbidden');
    //   }
    $ufile->assignTemplate('ufile');
    $ufile->tu_trip->assignTemplate('trip');
    return $ufile;
}
Пример #7
0
function admin_modeles_modinst()
{
    global $tpl;
    $modele = new Modele($_GET['modele']);
    $modele->fetch($_GET['key']);
    $tpl->assign('result', '');
    if (isset($_POST['action'])) {
        if ($modele->modFrom($_POST)) {
            $tpl->assign('result', 'success');
        } else {
            $tpl->assign('result', 'error');
        }
    }
    $tpl->assign('modele', $modele);
    $tpl->assign('edit', $modele->edit());
    $tpl->display('adminmodeles_modinst.tpl');
    quit();
}
Пример #8
0
function twofactors_set()
{
    global $tpl, $srcdir;
    $usr = new Modele('users');
    $usr->fetch($_SESSION['user']['user_id']);
    if ($_POST['activation'] == "true") {
        require_once $srcdir . '/libs/GoogleAuthenticator/GoogleAuthenticator.php';
        $otp = new GoogleAuthenticator();
        if (!$otp->checkCode($_SESSION['user']['GoogleAuthenticator'], $_POST['code'])) {
            $tpl->assign('hsuccess', "GoogleAuthentificator code invalide");
            modexec("index", "profile");
            quit();
        }
        $usr->user_otp = $_SESSION['user']['GoogleAuthenticator'];
    } else {
        $usr->user_otp = "";
    }
    $_SESSION['user']['user_otp'] = $usr->user_otp;
    redirect("index", "profile", array('hsuccess' => 1));
}
Пример #9
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()));
}
Пример #10
0
function section_admin_ml_noadmin()
{
    global $tpl, $srcdir, $pdo;
    include $srcdir . '/libs/GoogleApi.php';
    $api = new GoogleApi();
    $mdl = new Modele('sections');
    $mdl->fetch($_REQUEST['section']);
    $mdl->assignTemplate('section');
    $lnk = new Modele('section_ml');
    $lnk->find(array('sm_section' => $_REQUEST['section'], 'sm_ml' => $_REQUEST['ml']));
    $mbr = $api->getGroupMemberDetails($_REQUEST['ml'], $_REQUEST['member']);
    if (!$lnk->next() || strpos($_REQUEST['member'], 'save_') === 0 || $mbr->type == "GROUP") {
        modexec('syscore', 'forbidden');
    }
    $api->setGroupMemberLevel($lnk->sm_ml, $_REQUEST['member'], 'MEMBER');
    redirect("section", "admin_ml", array("hsuccess" => 1, "section" => $_REQUEST['section'], "ml" => $lnk->sm_ml));
}
Пример #11
0
function admin_note_downbulletin()
{
    global $pdo, $root;
    $mdl = new Modele("periods");
    $mdl->fetch($_GET['id']);
    $mdl->assignTemplate('bulletin');
    require $root . 'libs' . DS . 'bulletins' . DS . $mdl->period_generator . DS . 'bulletin.php';
    bulletin_download($_GET['id']);
    quit();
}
Пример #12
0
function trip_search()
{
    global $tpl;
    $mdl = new Modele('trips');
    $mdl->fetch($_GET['trip']);
    $mdl->assignTemplate('trip');
    if (isset($_POST['mailing'])) {
        redirect('trip', 'mail', array('search' => $_POST['search'], 'field' => $_POST['field'], 'value' => $_POST['value']));
    } else {
        $search = _trip_search_user($_POST['search'], $_GET['field'], $_GET['value']);
        while ($line = $search->fetch()) {
            $tpl->append('ufiles', $line);
        }
        $tpl->assign('search', $_POST['search']);
        $tpl->assign('field', $_GET['field']);
        $tpl->assign('value', $_GET['value']);
    }
    display();
}
Пример #13
0
 public function updateDB($id)
 {
     $mdl = new Modele('event_bocal');
     $mdl->fetch($id);
     $last = $this->answers[count($this->answers) - 1];
     if ($mdl->eb_state != $last->state || $mdl->eb_last_update != $last->date) {
         $mdl->eb_state = $last->state;
         $mdl->eb_last_update = $last->date;
         return true;
     }
     return false;
 }
Пример #14
0
function event_addpoints()
{
    global $tpl, $pdo;
    $event = new Modele('events');
    $event->fetch($_GET['event']);
    $event->assignTemplate('event');
    $section = new Modele('sections');
    $section->fetch($_REQUEST['section']);
    $section->assignTemplate('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', 'part_event' => $event->getKey());
        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 event_staff LEFT JOIN users ON user_id = est_user WHERE est_section = ? AND est_event = ?');
        $sql->bindValue(1, $section->getKey());
        $sql->bindValue(2, $event->getKey());
        $sql->execute();
        $mdlMark = new Modele('marks');
        $dataMark = array('mark_participation' => $mdl->getKey());
        while ($user = $sql->fetch()) {
            $markOk = $_POST['staff-' . $user['user_id'] . '-ok'];
            $markPeriod = $_POST['staff-' . $user['user_id'] . '-period'];
            $markMark = $_POST['staff-' . $user['user_id'] . '-mark'];
            if ($markOk == 'YES') {
                $dataMark['mark_user'] = $user['user_id'];
                $dataMark['mark_period'] = $markPeriod;
                $dataMark['mark_mark'] = $markMark;
                $mdlMark->addFrom($dataMark);
            }
        }
        redirect('event', 'staff_activities', array('event' => $event->getKey(), 'section' => $section->section_id, 'hsuccess' => '1'));
    }
    $types = new Modele('user_types');
    $types->find();
    $repPeriods = array();
    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();
        while ($period = $periods->fetch()) {
            if (!isset($repPeriods[$types->ut_id])) {
                $repPeriods[$types->ut_id] = array();
            }
            $repPeriods[$types->ut_id][] = $period;
        }
    }
    $tpl->assign('periods', $repPeriods);
    $sql = $pdo->prepare('SELECT * FROM event_staff LEFT JOIN users ON user_id =est_user WHERE est_section = ? AND est_event = ? ORDER BY user_name');
    $sql->bindValue(1, $section->getKey());
    $sql->bindValue(2, $event->getKey());
    $sql->execute();
    while ($user = $sql->fetch()) {
        $tpl->append('staffs', $user);
    }
    display();
}
Пример #15
0
function compta_delete()
{
    $mdlAcc = new Modele('user_accounts');
    $mdlAcc->fetch($_GET['account']);
    if ($mdlAcc->raw_ua_user == $_SESSION['user']['user_id']) {
        $mdlAcc->delete();
        redirect("compta", "index", array('hsuccess' => 1));
    }
    redirect("compta", "index", array('hsuccess' => 0));
}
Пример #16
0
function index_wizard()
{
    global $tpl;
    $mdl = new Modele('users');
    $mdl->fetch($_SESSION['user']['user_id']);
    $fields = null;
    if ($mdl->user_born == null) {
        $fields = array('user_phone', 'user_sexe', 'user_born');
        $tpl->assign('pcent', 25);
        _index_wizard_edit($mdl, $fields);
    }
    if ($fields == null && $mdl->raw_user_type == 0) {
        $fields = array('user_type');
        $tpl->assign('pcent', 50);
        _index_wizard_edit($mdl, $fields);
    }
    if ($fields == null && stripos($mdl->user_type->ut_name, 'EXTERNE') === false && $mdl->user_promo == 0) {
        $fields = array('user_promo', 'user_login');
        $tpl->assign('pcent', 85);
        _index_wizard_edit($mdl, $fields);
    }
    if ($fields == null) {
        // tous les champs sont OK
        redirect('index', 'index', array('hsuccess' => 1));
    }
    $tpl->assign('form', $mdl->edit($fields));
    display();
}
Пример #17
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');
}
Пример #18
0
function ml_removeSection()
{
    $mdl = new Modele('section_ml');
    $mdl->fetch($_REQUEST['lnk']);
    $ml = $mdl->sm_ml;
    $suc = $mdl->delete();
    redirect("ml", "view", array('ml' => $ml));
}
Пример #19
0
function bulletin_view_user($id)
{
    global $tpl, $srcdir;
    $mdl = new Modele('bulletin_user');
    $mdl->fetch($id);
    $bulletin = array('bu' => $mdl, 'data' => unserialize($mdl->bu_data), 'spice' => 0);
    foreach ($bulletin['data'] as $mark) {
        $bulletin['spice'] += $mark['duration'];
    }
    $tpl->assign('bulletin', $bulletin);
    $tpl->display($srcdir . '/libs/bulletins/epitech/user.tpl');
}
Пример #20
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();
}