Example #1
0
 public function activate()
 {
     //TODO: Implement this action.
     $uid = $_GET["uid"];
     $hash = $_GET["hash"];
     if (User::activateUser($uid, $hash)) {
         echo "active";
         User::loginSystem(User::fromUid($uid));
     }
     Page::redirect("/index");
 }
Example #2
0
<?php

/**
 * @author Jaco Ruit
 */
require 'startOrongo.php';
startOrongo('orongo-activation');
if (isset($_GET['code']) && !isset($_SESSION['orongo-id']) && !isset($_SESSION['orongo-session-id'])) {
    $code = $_GET['code'];
    if (User::isGoodActivationCode($code)) {
        $uid = User::getUserIDByActivationCode($code);
        if (!User::userIsActivated($uid)) {
            User::activateUser($uid);
            User::deleteActivationCode($code);
            header("Location: orongo-login.php?msg=6");
            exit;
        } else {
            @User::deleteActivationCode($code);
            header("Location: orongo-login.php?msg=5");
            exit;
        }
    } else {
        header("Location: orongo-login.php?msg=4");
        exit;
    }
} else {
    header("Location: orongo-login.php");
    exit;
}
Example #3
0
 public function actionAdmin()
 {
     $this->layout = 'admin';
     $this->setHeaderTitle('User administration');
     if (Rays::isPost()) {
         if (isset($_POST['checked_users'])) {
             $selected = $_POST['checked_users'];
             if (is_array($selected)) {
                 $operation = $_POST['operation_type'];
                 foreach ($selected as $id) {
                     switch ($operation) {
                         case "block":
                             User::blockUser($id);
                             break;
                         case "active":
                             User::activateUser($id);
                             break;
                     }
                 }
             }
         }
     }
     $searchStr = Rays::getParam('search', null);
     $query = User::find();
     if ($name = trim($searchStr)) {
         $names = preg_split("/[\\s]+/", $name);
         foreach ($names as $key) {
             $query = $query->like("name", $key);
         }
     }
     $page = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 10);
     $count = $query->count();
     $users = $query->order_desc("id")->order_desc("id")->range($pageSize * ($page - 1), $pageSize);
     $url = RHtml::siteUrl('user/admin' . ($searchStr != null ? '?search=' . urlencode(trim($searchStr)) : ""));
     if ($searchStr != null) {
         $url .= '?search=' . urlencode(trim($searchStr));
     }
     $pager = new RPager('page', $count, $pageSize, $url, $page);
     $data = ['count' => $count, 'users' => $users, 'pager' => $pager->showPager()];
     $this->render('admin', $data, false);
 }
Example #4
0
        header("Location: " . orongoURL("orongo-admin/create.php?msg=1&obj=page"));
        exit;
        break;
    case "user":
        if (getUser()->getRank() < RANK_ADMIN) {
            header("Location: " . orongoURL("orongo-admin/index.php?msg=0"));
            exit;
        }
        if (!isset($_POST['name']) || !isset($_POST['password']) || !isset($_POST['email']) || !isset($_POST['rank'])) {
            header("Location: " . orongoURL("orongo-admin/create.php?user"));
            exit;
        }
        if (User::usernameExists($_POST['name'])) {
            header("Location: " . orongoURL("orongo-admin/create.php?msg=0&obj=user"));
            exit;
        }
        try {
            $user = User::registerUser($_POST['name'], $_POST['email'], Security::hash($_POST['password']), $_POST['rank']);
            User::activateUser($user->getID());
        } catch (Exception $e) {
            header("Location: " . orongoURL("orongo-admin/create.php?msg=0&obj=user"));
            exit;
        }
        header("Location: " . orongoURL("orongo-admin/create.php?msg=1&obj=user"));
        exit;
        break;
    default:
        header("Location: " . orongoURL("orongo-admin/create.php"));
        exit;
        break;
}
Example #5
0
<?php

require_once "php/users.php";
// check if this is a email verification avatar of this page
if (isset($_GET['email']) && !empty($_GET['email']) && isset($_GET['token']) && !empty($_GET['token'])) {
    // Verify data
    if (User::activateUser($_GET['email'], $_GET['token'])) {
        // we are good
        $outputStr = "Thank you for joining travelmarket<br>your account is now active";
    } else {
        // give user the bad news
        $outputStr = "Sorry, there is no user with that name in our system.";
    }
    header("LOCATION: http://www.travelmarket.com?showpage=login");
    echo $outputStr;
}
     break;
 case 'activate':
     // activate/deactivate user account
     // this action is called via Ajax
     if (!Dot_Auth::checkUserToken($userToken)) {
         echo Zend_Json::encode(array("success" => false, "message" => "An error occured, please try again."));
         exit;
     }
     $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
     $isActive = isset($_POST['isActive']) ? $_POST['isActive'] : 0;
     $values = array('enum' => array('0' => '0,1', 'isActive' => $isActive));
     $dotValidateUser = new Dot_Validate_User(array('who' => 'user', 'action' => 'activate', 'values' => $values));
     if ($dotValidateUser->isValid()) {
         $data = $dotValidateUser->getData();
         // no error - then change active value of user
         $userModel->activateUser($id, $data['isActive']);
         $result = array("success" => true, "id" => $id, "isActive" => intval($data["isActive"]));
     } else {
         $result = array("success" => false, "message" => "An error occured, please try again.");
     }
     echo Zend_Json::encode($result);
     exit;
     break;
 case 'delete':
     // display confirmation form and delete user account
     if ($_SERVER['REQUEST_METHOD'] === "POST") {
         // changes were made to checkUserToken
         // see: Dot_Auth::checkUserToken($userToken, $userType='admin')
         // see: IndexController.php : $userToken
         if (!Dot_Auth::checkUserToken($userToken)) {
             // remove the identity