예제 #1
0
function forgotPwd()
{
    global $req;
    global $connection;
    global $module;
    $req->hasParams("email");
    $email = $req->getParam("email");
    $POST = array('email' => $email);
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('email', 'email', true, 2, 100, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $connection->close();
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Error: " . $errors);
    } else {
        $POST = $val->sanitized;
        $email = $module->escape($POST['email']);
        $output = $module->forgotPwd($email);
        if (is_bool($output)) {
            Res::sendInvalid($module->message);
        } else {
            $res = new Res();
            $res->send();
        }
    }
}
예제 #2
0
function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");
    $adminPhone = $req->getParam("adminPhone");
    $POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
    $genderValues = array('m', 'f', 'u');
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Errors:" . $errors);
    } else {
        $POST = $val->sanitized;
        $adminTable = new adminTable($connection);
        $adminUName = $adminTable->escape($POST['adminUName']);
        $adminFName = $adminTable->escape($POST['adminFName']);
        $adminGender = $adminTable->escape($POST['adminGender']);
        $adminEMail = $adminTable->escape($POST['adminEMail']);
        $adminPassword = $adminTable->escape($POST['adminPassword']);
        $adminPhone = $adminTable->escape($POST['adminPhone']);
        $adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
        if (is_bool($adminId)) {
            Res::sendInvalid("Errors:" . $adminTable->message);
        } else {
            $res = new Res();
            $res->addData("adminId", $adminId);
            $res->send();
        }
    }
}
예제 #3
0
 function login($user, $pwd, $rem)
 {
     global $adminSession;
     global $adminCookieUser;
     global $adminCookiePassword;
     global $invalidUserIdOrPassword;
     $POST = array('user' => $user, 'pwd' => $pwd, 'rem' => $rem);
     $val = new validation();
     $val->addSource($POST);
     $val->addRule('user', 'string', true, 1, 35, true)->addRule('pwd', 'string', true, 1, 35, true)->addRule('rem', 'bool');
     $val->run();
     if (sizeof($val->errors) > 0) {
         $connection->close();
         $errors = implode(" <br/> ", $val->errors);
         return "Error: " . $errors;
     } else {
         $POST = $val->sanitized;
         $user = $this->escape($POST['user']);
         $pwd = $this->escape($POST['pwd']);
         $rem = $this->escape($POST['rem']);
         $adminTable = new adminTable($this->connection);
         $result = $adminTable->verifyAdminLogin($user, $pwd);
         if (is_bool($result)) {
             return $invalidUserIdOrPassword;
         } else {
             if (!isset($_SESSION)) {
                 session_start();
             }
             $_SESSION[$adminSession] = $result;
             if ($rem) {
                 setcookie($adminCookieUser, $user, time() + 10 * 365 * 24 * 60 * 60, "/");
                 setcookie($adminCookiePassword, $pwd, time() + 10 * 365 * 24 * 60 * 60, "/");
             }
             return true;
         }
     }
 }
예제 #4
0
 $v1->addSource($_POST['course']);
 $v1->addRule('name', 'string', true, 1, 200, true);
 $v1->addRule('desc', 'string', true, 0, 999999, true);
 if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) {
     $v1->addRule('pictureId', 'numeric', true, 1, 999999, true);
 }
 foreach ($_POST['course'] as $key => $value) {
     if (preg_match('/^[0-9]{1,}$/', $key)) {
         $v1->addRule($key . "", 'numeric', true, 1, 200, true);
     }
 }
 if (isset($_POST['course']['users'])) {
     $v2->addSource($_POST['course']['users']);
     foreach ($_POST['course']['users'] as $key => $value) {
         if (preg_match('/^[0-9]{1,}$/', $key)) {
             $v2->addRule($key . "", 'numeric', true, 1, 200, true);
         }
     }
 }
 $v1->run();
 $v2->run();
 if (sizeof($v1->errors) > 0 || sizeof($v2->errors)) {
     $error_course_add = $v1->getMessageErrors() . "<br/>";
     $error_course_add .= $v2->getMessageErrors();
 } else {
     $cats = array();
     foreach ($v1->sanitized as $key => $value) {
         if (preg_match('/^[0-9]{1,}$/', $key) && isIdCategoryWpExist($value)) {
             $cats[] = $value;
         }
     }
예제 #5
0
            $v->addRule('courseId', 'numeric', true, 1, 99999, true);
        } else {
            $v->errors['courseId'] = $tr->__("You must create a course");
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_quiz_add = $v->getMessageErrors();
        } else {
            $currentUser = new StudyPressUserWP();
            $id_quiz = $managerQuiz->add(new Quiz(array('pictureUrl' => isset($v->sanitized['pictureurl']) ? $v->sanitized['pictureurl'] : '', 'name' => $v->sanitized['name'], 'author' => $currentUser->displayName(), 'authorId' => $currentUser->id(), 'courseId' => $v->sanitized['courseId'])));
        }
    }
}
if (isset($_POST['remove'])) {
    if (isset($_POST['id']) && !empty($_POST['id'])) {
        $v = new validation();
        $v->addSource($_POST['id']);
        foreach ($_POST['id'] as $key => $value) {
            $v->addRule($key, 'numeric', true, 1, 9999999, true);
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_quiz_remove = $v->getMessageErrors();
        } else {
            foreach ($v->sanitized as $value) {
                $managerQuiz->delete($value);
            }
        }
    }
}
require_once __ROOT_PLUGIN__ . "Views/admin/quiz.view.php";
예제 #6
0
<?php

require_once '_AutoLoadClassAjax.php';
if (isset($_POST['id']) && !empty($_POST['id'])) {
    $v = new validation();
    $v->addSource($_POST);
    $v->addRule('id', 'numeric', true, 1, 99999, true);
    $v->run();
    if (sizeof($v->errors) === 0) {
        $managerLesson = new LessonManager();
        $managerQuiz = new QuizManager();
        $activity = $managerLesson->getById($v->sanitized['id']);
        if (!$activity) {
            $activity = $managerQuiz->getById($v->sanitized['id']);
        }
        if ($activity) {
            if (StudyPressUserWP::isLoggedIn()) {
                $currentUserId = new StudyPressUserWP();
                $currentUserId = $currentUserId->id();
                $managerLesson->setVisitedActivity($currentUserId, $activity->getId());
            }
        }
    }
}
예제 #7
0
                     if (isset($v1->sanitized['pictureId'])) {
                         $course->setPictureId($v1->sanitized['pictureId']);
                     }
                     $managerCourse->update($course->getId(), $course);
                 }
             }
         } else {
             $error_course_update = $tr->__("Please select at least one author") . "<br/>" . $tr->__("Please select at least one category") . "<br/>" . $tr->__("Please enter a valid name");
         }
     } else {
         // if is an author
         $v = new validation();
         $v->addSource($_POST['course']);
         $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true)));
         if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) {
             $v->addRule('pictureId', 'numeric', true, 1, 999999, true);
         }
         $v->run();
         if (sizeof($v->errors)) {
             $error_course_update = $v->getMessageErrors();
         } else {
             if ($course = $managerCourse->getById($v->sanitized['id'])) {
                 $course->setDescription($v->sanitized['description']);
                 if (isset($v->sanitized['pictureId'])) {
                     $course->setPictureId($v->sanitized['pictureId']);
                 }
                 $managerCourse->update($course->getId(), $course);
             }
         }
     }
 }
예제 #8
0
                    }
                }
            }
        }
    }
}
if (isset($_POST['type']) && $_POST['type'] === "share-groups") {
    if (isset($_POST['quizId']) && !empty($_POST['quizId']) && isset($_POST['groups'])) {
        require_once "_AutoLoadClassAjax.php";
        global $tr;
        $c = new Configuration();
        $c = $c->getConfig();
        if ($c['bp_shareResult'] = 'true') {
            $v = new validation();
            $v->addSource($_POST);
            $v->addRule('quizId', 'numeric', true, 1, 9999999, true);
            $v->run();
            if (sizeof($v->errors) > 0) {
                header("HTTP/1.0 400 Bad Request");
                echo $v->getMessageErrors();
            } else {
                $manager = new QuizManager();
                $type = "quiz";
                $activity = $manager->getById($v->sanitized['quizId']);
                if (!$activity) {
                    $manager = new LessonManager();
                    $type = "lesson";
                    $activity = $manager->getById($v->sanitized['quizId']);
                }
                if ($activity) {
                    if (StudyPressUserWP::isLoggedIn()) {