function _request_new_password()
{
    if (isset($_POST['email'])) {
        $user = new User(getdbh());
        $ID = $user->checkEmail($_POST['email']);
        if (isset($ID['ID'])) {
            $setToken = $user->setRecover($ID['ID'], $_POST['email']);
            if ($setToken != false) {
                $body = 'Pentru a schimba parola apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/recover_password/' . $setToken . '"> AICI </a>';
                if (sendEmail('Schimbare parola', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de resetare a parolei a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul nu a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Tokenul este gresit sau au trecut mai mult de 2 zile de la cererea de recuperare parola";
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Acest user nu exista";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    } else {
        redirect('main/index');
    }
}
Example #2
0
function _make_user_table($n, &$data)
{
    $dbh = getdbh();
    //pagination
    $stmt = $dbh->query('SELECT count(*) "total" FROM "users"');
    $rs = $stmt->fetch(PDO::FETCH_ASSOC);
    $total = $rs['total'];
    $limit = $GLOBALS['pagination']['per_page'];
    $data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
    $data['body'][] = pagination::makePagination($n, $total, myUrl('users/manage'), $GLOBALS['pagination']);
    //table
    $stmt = $dbh->query("SELECT * FROM \"users\" LIMIT {$n},{$limit}");
    $tablearr[] = explode(',', 'uid,username,password,fullname,created_dt,Action');
    while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $uid = $rs['uid'];
        $row = null;
        foreach ($rs as $k => $v) {
            $row[$k] = htmlspecialchars($v);
        }
        $row[] = '<a href="' . myUrl("users/edit/{$uid}") . '">Edit</a> | <a href="javascript:jsconfirm(\'Really Delete User?\',\'' . myUrl("users/ops_delete/{$uid}") . '\')">Delete</a>';
        $tablearr[] = $row;
    }
    $data['body'][] = table::makeTable($tablearr);
    $data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}
function _addGrupaMember()
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    $checkGroup = $grupa->checkGroupRegistration($_POST['userID']);
    if ($checkGroup != false) {
        if ($checkGroup['ID_GRUPA'] != $_POST['grupaID']) {
            $delete = $grupa->deleteGrupaMember($checkGroup['ID']);
        }
    }
    $check = $grupa->checkRegister($_POST['grupaID'], $_POST['userID']);
    if ($check == false) {
        $addMember = $grupa->addGrupaMember($_POST['grupaID'], $_POST['userID']);
        if ($addMember) {
            $data['msg'][] = "Studentul a fost inscris in grupa";
            $data['redirect'][] = 'administrare/show_grup';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        } else {
            $data['msg'][] = "Eroare la inscriere";
            $data['redirect'][] = 'administrare/show_grup';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    } else {
        $data['msg'][] = "Studentul este inscris la aceasta grupa";
        $data['redirect'][] = 'administrare/show_grup';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
Example #4
0
function _make_html_table($n, &$data)
{
    $dbh = getdbh();
    //pagination
    $stmt = $dbh->query('SELECT count(OID) total FROM t_user');
    $total = $stmt->fetchColumn();
    $limit = $GLOBALS['pagination']['per_page'];
    $data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
    $data['body'][] = pagination::makePagination($n, $total, myUrl('mgmt_user/manage'), $GLOBALS['pagination']);
    //table
    $stmt = $dbh->query("SELECT OID,CID,permissions,username,fullname FROM t_user LIMIT {$n},{$limit}");
    $tablearr[] = explode(',', 'username,roll,fullname');
    while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $OID = $rs['OID'];
        $CID = $rs['CID'];
        $row = null;
        $row['username'] = htmlspecialchars($rs['username']);
        $row['roll'] = htmlspecialchars(User::getPermissionsAsRollText($rs['permissions']));
        $row['fullname'] = htmlspecialchars($rs['fullname']);
        $row[] = '<a href="' . myUrl("mgmt_user/edit/{$OID}/{$CID}") . '">Edit</a> | <a href="javascript:jsconfirm(\'Really Delete User?\',\'' . myUrl("mgmt_user/ops_delete/{$OID}/{$CID}") . '\')">Delete</a>';
        $tablearr[] = $row;
    }
    $data['body'][] = table::makeTable($tablearr);
    $data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}
function _newUser()
{
    $user = new User(getdbh());
    $email = $user->checkEmail($_POST['email']);
    if (isset($email['ID'])) {
        $data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
        $data['redirect'][] = 'main/new';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
        if ($result > 0) {
            $setToken = $user->newUserToken($result);
            if ($setToken != false) {
                $body = 'Pentru a activa contul apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
                if (sendEmail('Email confirmare cont', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Eroare la generarea tokenului";
                $data['redirect'][] = 'main/index';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Eroare la crearea contului!";
            $data['redirect'][] = 'main/index';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
function _showAllMat()
{
    $materie = new Materii(getdbh());
    $result['materii'] = $materie->fetchMaterii();
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'showAllMat.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
Example #7
0
function _make_html_table($table, $item, $urlPrefix, $n, &$data)
{
    $dbh = getdbh();
    //pagination
    $stmt = $dbh->query("SELECT count(OID) total FROM {$table}");
    $total = $stmt->fetchColumn();
    $limit = $GLOBALS['pagination']['per_page'];
    $data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
    $data['body'][] = pagination::makePagination($n, $total, myUrl("{$urlPrefix}/manage"), $GLOBALS['pagination']);
    //table
    $fields = "URL,stationId,lastContact,debug";
    $stmt = $dbh->query("SELECT OID,CID,{$fields} FROM {$table} LIMIT {$n},{$limit}");
    if ($stmt === false) {
        var_dump($dbh->errorInfo());
        return;
    }
    $tablearr[] = explode(',', $fields);
    while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $OID = $rs['OID'];
        $CID = $rs['CID'];
        $row = null;
        foreach ($tablearr[0] as $f) {
            $row[] = htmlspecialchars($rs[$f]);
        }
        $row[] = '<a href="' . myUrl("{$urlPrefix}/ops_reset/{$OID}/{$CID}") . '">Reset</a> | ' . '<a href="' . myUrl("{$urlPrefix}/ops_shutdown/{$OID}/{$CID}") . '">Shutdown</a> | ' . '<a href="' . myUrl("{$urlPrefix}/edit/{$OID}/{$CID}") . '">Edit</a> | ' . '<a href="javascript:jsconfirm(\'Really Delete ' . $item . '?\',\'' . myUrl("{$urlPrefix}/ops_delete/{$OID}/{$CID}") . '\')">Delete</a>';
        $tablearr[] = $row;
    }
    $data['body'][] = table::makeTable($tablearr);
    $data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}
Example #8
0
 function delete_machine($serial_number = '')
 {
     $status = array('status' => 'undefined', 'rowcount' => 0);
     if (!$this->authorized('delete_machine')) {
         $status['status'] = 'unauthorized';
     } else {
         // Delete machine entry from all tables
         $machine = new Machine_model();
         // List tables (unfortunately this is not db-agnostic)
         switch ($machine->get_driver()) {
             case 'sqlite':
                 $tbl_query = "SELECT name FROM sqlite_master \n\t\t\t\t\t\tWHERE type = 'table' AND name NOT LIKE 'sqlite_%'";
                 break;
             default:
                 // Get database name from dsn string
                 if (conf('dbname')) {
                     $tbl_query = "SELECT TABLE_NAME AS name FROM information_schema.TABLES \n\t\t\t\t\t\tWHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='" . conf('dbname') . "'";
                 } else {
                     die('Admin:delete_machine: Cannot find database name.');
                 }
         }
         // Get tables
         $tables = array();
         foreach ($machine->query($tbl_query) as $obj) {
             $tables[] = $obj->name;
         }
         // Get database handle
         $dbh = getdbh();
         $dbh->beginTransaction();
         // Affected rows counter
         $cnt = 0;
         // Delete entries
         foreach ($tables as $table) {
             // Migration has no serial number
             if ($table == 'migration') {
                 continue;
             }
             // hash and inventoryitem use serial FIXME
             if ($table == 'hash' or $table == 'inventoryitem') {
                 $serial = 'serial';
             } else {
                 $serial = 'serial_number';
             }
             $sql = "DELETE FROM {$table} WHERE `{$serial}`=?";
             if (!($stmt = $dbh->prepare($sql))) {
                 die('Prepare ' . $sql . ' failed');
             }
             $stmt->bindValue(1, $serial_number);
             $stmt->execute();
             $cnt += $stmt->rowCount();
         }
         $dbh->commit();
         // Return status
         $status['status'] = 'success';
         $status['rowcount'] = $cnt;
     }
     $obj = new View();
     $obj->view('json', array('msg' => $status));
 }
function _addMaterii()
{
    isUserLoggedIn();
    $user = new User(getdbh());
    $result['profesori'] = $user->fetchByType('profesor');
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'addMaterii.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _show_materii()
{
    $materii = new Materii(getdbh());
    $allMaterii = $materii->fetchGroupaAndMateria();
    $result['materii'] = $allMaterii;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_materii.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _show_users()
{
    isUserLoggedIn();
    $user = new User(getdbh());
    $user_details = $user->fetchAll();
    $result['user'] = $user_details;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_user.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _show_grup()
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    $allGroups = $grupa->fetchAll();
    $result['grupa'] = $allGroups;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_grupa.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _showGrupaDetails($id = 0, $numeGrupa = '')
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    $result['users'] = $grupa->fetchGrupaUsers($id);
    $result['nume'] = $numeGrupa;
    $result['id'] = $id;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'showGrupaDetails.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _addGrupaUsers($id = 0)
{
    isUserLoggedIn();
    $user = new User(getdbh());
    $getUsers = $user->fetchAll();
    $result['user'] = $getUsers;
    $result['grupaID'] = $id;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'addUserGrupa.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _addTemaView()
{
    isUserLoggedIn();
    if (getUserType() == 'profesor') {
        $grupa = new Grupa(getdbh());
        $result['grupa'] = $grupa->fetchAll();
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'addTema.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _add_new_password()
{
    if (isset($_POST['password1']) && isset($_POST['password2']) && isset($_POST['id'])) {
        $user = new User(getdbh());
        $result = $user->newPassword($_POST['password1'], $_POST['id']);
        if ($result) {
            $data['msg'][] = "Parola a fost schimbata cu success";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        } else {
            $data['msg'][] = "Eroare. Parola nu a fost schimbata. Trimite o noua cerere de schimbare a parolei";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
function _updateMaterii()
{
    isUserLoggedIn();
    $materii = new Materii(getdbh());
    $result = $materii->updateMaterii($_POST['idMaterie'], $_POST['credite'], $_POST['denumire'], $_POST['idProf']);
    if ($result) {
        $data['msg'][] = 'Materia a fost modificata cu success';
        $data['redirect'][] = 'administrare/show_materii';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la modificarea materiei";
        $data['redirect'][] = 'administrare/show_materii';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _recover_password($token = '')
{
    //verificarea daca tokenul mai este valid
    if (!is_null($token)) {
        $user = new User(getdbh());
        $result = $user->checkToken($token);
        if (isset($result['ID']) && isset($result['EMAIL'])) {
            $id['user'] = $result;
            $data['msg'][] = View::do_fetch(VIEW_PATH . 'new_pass.tpl.php', $id);
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        } else {
            redirect('error/404');
        }
    }
}
function _showNews()
{
    isUserLoggedIn();
    if (getUserType() == 'admin' || getUserType() == 'profesor') {
        $noutate = new Noutati(getdbh());
        $result['noutate'] = $noutate->fetchAll();
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'noutatiProf.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $noutate = new Noutati(getdbh());
        $result['noutate'] = $noutate->fetchAll();
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'noutatiStudent.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _newUserToken($token = '')
{
    if (!is_null($token)) {
        $user = new User(getdbh());
        $result = $user->checkConfirmationToken($token);
        if (isset($result['ID']) && isset($result['EMAIL'])) {
            if ($setStatus = $user->setStatus($result['ID'], 'NO_GROUP')) {
                $data['msg'][] = 'Emailul a fost confirmat';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            redirect('error/404');
        }
    }
}
function _showTeme()
{
    isUserLoggedIn();
    if (getUserType() == 'admin' || getUserType() == 'profesor') {
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeProfesor.tpl.php');
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $grupaMea = new Grupa(getdbh());
        $result = $grupaMea->getGrupaUserCurent(getUserID());
        $idGrupaMea = (int) $result[0]['ID_GRUPA'];
        $tema = new Teme(getdbh());
        $result['tema'] = $tema->getTemeStudentCurent($idGrupaMea);
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeStudent.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _addNews()
{
    $user = new User(getdbh());
    $userDetails = $user->getUserDetails($_SESSION['uid']);
    $noutate = new Noutati(getdbh());
    $autor = $userDetails[0]['NUME'] . " " . $userDetails[0]['PRENUME'];
    if ($noutate->addNews($autor, $_POST['noutate'])) {
        $data['msg'][] = 'Noutatea a fost adaugata cu success';
        $data['redirect'][] = 'news/showNews';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = 'Noutatea nu a fost adaugata';
        $data['redirect'][] = 'news/showNews';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
Example #23
0
function _resetdb()
{
    $dbh = getdbh();
    $dbh->exec('DROP TABLE "users"');
    $dbh->exec('VACUUM');
    $sql = 'CREATE TABLE "users" ("uid" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , "username" VARCHAR NOT NULL , "password" VARCHAR NOT NULL , "fullname" , "created_dt" DATETIME)';
    $dbh->exec($sql);
    $dbh->exec("INSERT INTO users (username,password,fullname,created_dt) VALUES ('admin','pass','Tester','" . date('Y-m-d H:i:s') . "')");
    for ($i = 1; $i < 21; $i++) {
        $username = '******' . $i;
        $password = '******' . $i;
        $fullname = 'User #' . $i;
        $dbh->exec("INSERT INTO users (username,password,fullname,created_dt) VALUES ('{$username}','{$password}','{$fullname}','" . date('Y-m-d H:i:s') . "')");
    }
    redirect('main', 'Database Initialized!');
}
function _suportCurs()
{
    isUserLoggedIn();
    if (getUserType() == 'student') {
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'suport_curs_stud.php');
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $grupa = new Grupa(getdbh());
        $getGroups = $grupa->fetchAll();
        $result['grupa'] = $getGroups;
        $materie = new Materii(getdbh());
        $getMaterii = $materie->fetchGroupaAndMateria();
        $result['materie'] = $getMaterii;
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'suport_curs_prof.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _check_login()
{
    //TODO
    //$user = new User(getdbh());
    //$user->checkPassword();
    //redirect fie catre main page fie inapoi catre login
    //$_POST contine datele din form trimise de user
    $user = new User(getdbh());
    $user_details = $user->checkPassword($_POST['email'], $_POST['password']);
    if (count($user_details) == 1) {
        //TODO adauga in sesiune user id, si user type ($user_details['ID'])
        $_SESSION['uid'] = $user_details[0]['ID'];
        $_SESSION['type'] = $user_details[0]['TIP'];
        redirect('main/index');
    } else {
        redirect('main/login');
    }
}
function _adminTeme()
{
    isUserLoggedIn();
    switch ($_POST['actiune']) {
        case 'add':
            $tema = new Teme(getDbh());
            $materii = new Materii(getdbh());
            // $fetch = $materii->getMateriiDetails($_POST['grupaID']);
            $fetch = $materii->getMateriiDetails(1);
            if ($_FILES['fileToUpload']['name'] != '') {
                if ($_FILES['fileToUpload']['size'] > 5242880) {
                    redirect('teme1');
                }
                $file = $_FILES['fileToUpload']['tmp_name'];
                $new_file_name = strtolower($_FILES['fileToUpload']['name']);
                $FileType = pathinfo($new_file_name, PATHINFO_EXTENSION);
                if ($FileType != "xml" && $FileType != "png" && $FileType != "bmp" && $FileType != "jpg" && $FileType != "gif" && $FileType != "doc" && $FileType != "docx" && $FileType != "pdf") {
                    echo "Sorry, only JPG, PNG, GIF, DOC, DOCX, BMP, PDF, XML files are allowed.";
                    redirect('teme2');
                }
            }
            if ($_FILES['fileToUpload']['name'] != '') {
                $result = $tema->addTema($fetch['ID_USER'], $_POST['grupaID'], $_POST['materie'], $_POST['denumire'], $_POST['detalii'], $file);
            } else {
                $result = $tema->addTema($fetch['ID_USER'], $_POST['grupaID'], $_POST['materie'], $_POST['denumire'], $_POST['detalii']);
            }
            if ($result) {
                $data['msg'][] = "Tema de licenta a fost adaugata  cu success";
                $data['redirect'][] = 'teme';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            } else {
                $data['msg'][] = "Eroare la adaugare";
                $data['redirect'][] = 'teme';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
            break;
        case 'edit':
        case 'delete':
            break;
        default:
            //echo "wrong action"
            break;
    }
}
function _updateGrupa()
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    if (isset($_POST['sef_grupa'])) {
        $result = $grupa->updateGrupa($_POST['idGrupa'], $_POST['nume'], $_POST['an'], $_POST['profil'], $_POST['sef_grupa']);
    } else {
        $result = $grupa->updateGrupa($_POST['idGrupa'], $_POST['nume'], $_POST['an'], $_POST['profil']);
    }
    if ($result) {
        $data['msg'][] = 'Grupa a fost modificata cu success';
        $data['redirect'][] = 'administrare/show_grup';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la modificarea grupei";
        $data['redirect'][] = 'administrare/show_grup';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _adminNews($actiune = '', $id = 0)
{
    switch ($actiune) {
        case 'edit':
            $noutate = new Noutati(getdbh());
            $result['noutate'] = $noutate->fetchNews($id);
            $data['msg'][] = View::do_fetch(VIEW_PATH . 'modificaNoutate.tpl.php', $result);
            View::do_dump(VIEW_PATH . 'layout.php', $data);
            break;
        case 'delete':
            $noutate = new Noutati(getdbh());
            $stergere = $noutate->deleteNews($id);
            if ($stergere > 0) {
                $data['msg'][] = "Noutatea a fost stersa cu success";
                $data['redirect'][] = 'news/showNews';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            } else {
                $data['msg'][] = "Eroare la stergerea noutatii";
                $data['redirect'][] = 'news/showNews';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
            break;
        case 'editDone':
            $noutate = new Noutati(getdbh());
            $editNoutate = $noutate->updateNews($id, $_POST['noutate']);
            if ($editNoutate) {
                $data['msg'][] = "Noutatea a fost modificata cu success ";
                $data['redirect'][] = 'news/showNews';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            } else {
                $data['msg'][] = "Noutatea nu a  fost modificata";
                $data['redirect'][] = 'news/showNews';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
            break;
        default:
            redirect('main/index');
            break;
    }
}
Example #29
0
function _make_html_ext_table($view, $item, $urlPrefix, &$data)
{
    $dbh = getdbh();
    //view
    $fields = "Name,towerD,towerH,Duration,Score";
    $stmt = $dbh->query("SELECT {$fields} FROM {$view}");
    if ($stmt === false) {
        var_dump($dbh->errorInfo());
        return;
    }
    $fields = explode(',', $fields);
    $tablearr[] = explode(',', "Name,Location Accuracy,Height Accuracy,Duration,Score");
    while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $row = null;
        foreach ($fields as $f) {
            $row[] = htmlspecialchars($rs[$f]);
        }
        $tablearr[] = $row;
    }
    $data['head'][] = '<meta http-equiv="refresh" content="' . $GLOBALS['leaderBoardRefresh'] . '">';
    $data['body'][] = table::makeTable($tablearr);
}
function _make_html_table($n, &$data)
{
    $dbh = getdbh();
    //pagination
    $stmt = $dbh->query('SELECT count(OID) total FROM t_event');
    $total = $stmt->fetchColumn();
    $limit = $GLOBALS['pagination']['per_page'];
    $data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
    $data['body'][] = pagination::makePagination($n, $total, myUrl('mgmt_main/manage'), $GLOBALS['pagination']);
    //table
    $stmt = $dbh->query("SELECT created_dt,teamId,stationId,points,data FROM t_event LIMIT {$n},{$limit}");
    $tablearr[] = explode(',', 'created_dt,teamId,stationId,points,data');
    while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $row = null;
        foreach ($tablearr[0] as $f) {
            $row[] = htmlspecialchars($rs[$f]);
        }
        $tablearr[] = $row;
    }
    $data['body'][] = table::makeTable($tablearr);
    $data['body'][] = '<p><a href="' . myUrl("mgmt_main") . '">Back</a></p>';
    $data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}