Example #1
1
function showEventBrief($idEvent, $showRelationship = true)
{
    if (!isUserLoggedIn()) {
        throw new RuntimeException("You need to be logged in.");
    }
    if (!canSeeEvent($_SESSION["userid"], $idEvent)) {
        throw new RuntimeException("You do not have access to this event.");
    }
    $event = getEvent($idEvent);
    $canEdit = isUserLoggedIn() && $event["owner"] === getUserID();
    echo '<div class="event_brief" id="event' . $idEvent . '">';
    echo '<div class="name"><a href="view_event.php?id=' . $idEvent . '">';
    echo '<h2>' . htmlspecialchars($event["name"]) . '</h2>';
    echo '</a></div>';
    if ($showRelationship) {
        if ($canEdit) {
            echo '<div class="owner"></div>';
        } else {
            if (isUserRegisteredInEvent(getUserID(), $idEvent)) {
                echo '<div class="registered"></div>';
            } else {
                echo '<div class="not_registered"></div>';
            }
        }
    }
    echo '<img src="database/event_image.php?id=' . $idEvent . '" alt="' . htmlspecialchars($event["name"]) . '" width="64" height="64" />';
    echo '<div class="description">';
    echo '<p class="description">' . htmlspecialchars($event["description"]) . '</p>';
    echo '</div>';
    echo '<datetime>' . htmlspecialchars($event["date"]) . '</datetime>';
    echo '</div>';
}
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 #3
0
 public function index()
 {
     /*
     UserCake (Via CupCake) Version: 2.0.2
     http://usercake.com
     */
     global $loggedInUser;
     $baseURL = getcwd();
     require_once "{$baseURL}/application/third_party/user_cake/models/config.php";
     if (!securePage($_SERVER['PHP_SELF'])) {
         die;
     }
     //Log the user out
     if (isUserLoggedIn()) {
         $loggedInUser->userLogOut($this);
     }
     $s_u = site_url();
     if (!empty($s_u)) {
         $add_http = "";
         if (strpos(site_url(), "http://") === false) {
             $add_http = "http://";
         }
         header("Location: " . $add_http . str_replace('.php', '', site_url()));
         die;
     } else {
         header("Location: http://" . $_SERVER['HTTP_HOST']);
         die;
     }
 }
Example #4
0
function authenticateUser($redirectUrl)
{
    checkSession();
    if (!isUserLoggedIn()) {
        redirect($redirectUrl);
    }
}
function _index()
{
    //	$data['msg'][]=View::do_fetch(VIEW_PATH.'login.tpl.php');
    //	View::do_dump(VIEW_PATH.'layout.php',$data);
    isUserLoggedIn();
    redirect('news/showNews');
}
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);
}
Example #7
0
function checkLogin()
{
    if (!isUserLoggedIn()) {
        echo parseSite("login", array());
        return false;
    } else {
        return true;
    }
}
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 _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 _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 _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);
}
Example #13
0
function getReferralPage()
{
    if (isset($_SESSION['referral_page'])) {
        return $_SESSION['referral_page'];
    } else {
        if (isUserLoggedIn()) {
            return ACCOUNT_ROOT;
        } else {
            return SITE_ROOT;
        }
    }
}
 function updateUserPick($pick = NULL, $pool = NULL)
 {
     global $loggedInUser, $db, $db_table_prefix;
     if (isUserLoggedIn()) {
         $round = json_decode($this->getCurrentRound())->round;
         $sql = "UPDATE " . $db_table_prefix . "pool" . $pool . " SET pick = '" . $pick . "' WHERE \n\t\t\tuserId = " . $loggedInUser->user_id . " AND\n\t\t\troundPicked = '" . $round . "'";
         $picks = $db->sql_query($sql);
         var_dump($picks);
         return '{"success":  ' . json_encode($picks) . '}';
     }
     return false;
 }
Example #15
0
 public static function generate($_asJson = true)
 {
     $result = array();
     $publicKey = sha1(mt_rand_str(40));
     $privateKey = sha1(mt_rand_str(40));
     #if(CWM_API::IsTokenValid($tokenValue)) {
     if (isUserLoggedIn()) {
         $result = array('public' => $publicKey, 'private' => $privateKey);
     }
     if ($_asJson) {
         $result = CWM_API::getAsJson($result);
     }
     return $result;
 }
function _deleteGrupaMember()
{
    isUserLoggedIn();
    switch ($_POST['actiune']) {
        case 'delete':
            reset($_POST);
            $key = key($_POST);
            $grupaId = explode("_", $key);
            $grupa = new Grupa(getDbh());
            $deleteMember = $grupa->deleteGrupaMember($grupaId[1]);
            if ($deleteMember) {
                $data['msg'][] = "Studentul a fost scos din grupa";
                $data['redirect'][] = 'administrare/show_grup';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            } else {
                $data['msg'][] = "Eroare la stergerea din grupa";
                $data['redirect'][] = 'administrare/show_grup';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
            break;
        case 'delete_all':
            $sterse = 0;
            $nesterse = 0;
            $grupa = new Grupa(getDbh());
            foreach ($_POST as $key) {
                if ($key == 'delete_all' || $key == 'Sterge tot') {
                    continue;
                } else {
                    $grupaID = explode("_", $key);
                    $deleteMember = $grupa->deleteGrupaMember($grupaID[1]);
                    if ($deleteMember) {
                        $sterse++;
                    } else {
                        $nesterse++;
                    }
                }
            }
            if ($sterse > 0) {
                $data['msg'][] = $sterse . " studenti au fost stersi cu success";
                $data['redirect'][] = 'administrare/show_grup';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            } else {
                $data['msg'][] = $nesterse . " studenti nu au fost stersi";
                $data['redirect'][] = 'administrare/show_grup';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
            break;
    }
}
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 _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 _adaugareUser()
{
    isUserLoggedIn();
    $user = new User(getDbh());
    $result = $user->addUserByProf($_POST['nume'], $_POST['prenume']);
    if ($result) {
        $data['msg'][] = 'Studentul a fost adaugat cu success';
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la adaugarea studentului";
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
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);
    }
}
Example #21
0
function getMenuPages()
{
    $pages = array();
    if (isUserLoggedIn()) {
        $pages["user_profile.php"] = "Profile";
        $pages["public_events.php"] = "Public Events";
        $pages["my_events.php"] = "My events";
        $pages["invited_events.php"] = "Upcoming Invites";
        $pages["create_event.php"] = "Create event";
        $pages["event_history.php"] = "Event History";
        $pages["logout.php"] = "Logout";
    } else {
        $pages["login.php"] = "Login";
        $pages["register.php"] = "Register";
    }
    return $pages;
}
function apiReturnError($ajax = false, $failure_landing_page = null)
{
    // Default page
    if ($failure_landing_page == null) {
        if (isUserLoggedIn()) {
            $failure_landing_page = ACCOUNT_ROOT . "404.php";
        } else {
            $failure_landing_page = SITE_ROOT . "login.php";
        }
    }
    if ($ajax) {
        echo json_encode(array("errors" => 1, "successes" => 0));
    } else {
        header('Location: ' . $failure_landing_page);
    }
    exit;
}
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);
    }
}
Example #24
0
/**
 * A global function required to determine if a permission is granted for this user using the forum.
 * @param Permission $permission
 * @param ForumElement $element
 * @return boolean True if permission is granted.
 */
function hasPermission($user, $comparePermission, $element)
{
    global $loggedInUser, $permission;
    if (!isUserLoggedIn()) {
        return false;
    }
    if ($loggedInUser->checkPermission(array(2))) {
        return true;
    }
    /**
     * UE Modder Special Permission
     */
    if ($loggedInUser->checkPermission(array(4))) {
        return $comparePermission == $permission["thread_lock"];
    }
    return false;
}
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;
    }
}
Example #26
0
 public function processApi()
 {
     global $loggedInUser;
     // Extract requested API
     $func = isset($_REQUEST['action']) ? strtolower(trim(str_replace("/", "", $_REQUEST['action']))) : null;
     if (!$func && isset($_POST['action'])) {
         $func = $_POST['action'];
     }
     // Extract API key
     if (isUserLoggedIn() && $loggedInUser != NULL) {
         // if logged in, we get it from current cookie
         $key = $loggedInUser->activationtoken();
     } else {
         $key = strtolower(trim(str_replace("/", "", $_REQUEST['token'])));
         if (!$key && isset($_POST['token'])) {
             $key = $_POST['token'];
         }
     }
     // Verify API key/ Save user id in REQUEST array
     $is_api_valid = loggedInUser::checkapikey($key);
     $user = loggedInUser::getuserbyapikey($key);
     if ($user != null) {
         $_REQUEST["user"] = $user;
     }
     // Go to selected route
     if (!$is_api_valid) {
         $this->response('', 401);
     } else {
         if ((int) method_exists($this, $func) > 0) {
             $this->{$func}();
         } else {
             if ($this->get_request_method() == "DELETE" || isset($_REQUEST) && isset($_REQUEST['_method']) && $_REQUEST['_method'] == 'DELETE') {
                 $this->deletefile();
             } else {
                 if (isset($_REQUEST) && isset($_REQUEST['download'])) {
                     $this->downloadfile();
                 } else {
                     $this->response('', 404);
                 }
             }
         }
     }
 }
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);
    }
}
Example #28
0
function doAction($action, $url = "")
{
    $forwardpage = "";
    $forward = true;
    $loggedin = isUserLoggedIn();
    if (!$loggedin && strcmp($action, "install") != 0 && strcmp($action, "redirect") != 0) {
        $action = "";
    }
    if (strcmp($action, "install") == 0) {
        $forwardpage = "views/install.php";
    } else {
        if (strcmp($action, "redirect") == 0) {
            $forwardpage = "views/redirect.php";
        } else {
            if (strcmp($action, "") == 0) {
                if ($loggedin) {
                    doAction("home");
                    $forward = false;
                } else {
                    include 'login.php';
                }
            } else {
                if (strcmp($action, "home") == 0) {
                    include 'home.php';
                } else {
                    if (strcmp($action, "logout") == 0) {
                        include 'logout.php';
                    } else {
                        if (strcmp($action, "createGrid") == 0) {
                            include 'createGrid.php';
                        }
                    }
                }
            }
        }
    }
    if ($forward == true) {
        include $forwardpage;
    }
}
Example #29
0
function doAction($action)
{
    $forwardpage = "";
    $forward = true;
    $loggedin = isUserLoggedIn();
    if (!$loggedin && strcmp($action, "login") != 0 && strcmp($action, "register") != 0 && strcmp($action, "getTags") != 0) {
        addError("fatal", "user.unathorized");
        outputJSON("error");
    } else {
        if (strcmp($action, "login") == 0) {
            login();
        } else {
            if (strcmp($action, "logout") == 0) {
                logout();
            } else {
                if (strcmp($action, "isLoggedIn") == 0) {
                    isLoggedIn();
                } else {
                    if (strcmp($action, "register") == 0) {
                        register();
                    } else {
                        if (strcmp($action, "addquestion") == 0) {
                            addQuestion();
                        } else {
                            if (strcmp($action, "getTags") == 0) {
                                getTags();
                            } else {
                                if (strcmp($action, "getquestions") == 0) {
                                    getQuestions();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
function _updateUser()
{
    isUserLoggedIn();
    $user = new User(getdbh());
    $grupa = new Grupa(getdbh());
    if ($_POST['currentGroup'] > 0 && $_POST['currentGroup'] != $_POST['grupa']) {
        $remove = $grupa->removeGroupMember($_POST['currentGroup'], $_POST['idUser']);
    }
    $check = $grupa->checkRegister($_POST['grupa'], $_POST['idUser']);
    if ($check == false) {
        $addGrupa = $grupa->addGrupaMember($_POST['grupa'], $_POST['idUser']);
    }
    $result = $user->updateUser($_POST['idUser'], $_POST['email'], $_POST['nume'], $_POST['prenume'], $_POST['type'], $_POST['status']);
    if ($result) {
        $data['msg'][] = 'Userul a fost modificat cu success';
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la modificarea userului";
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}