Пример #1
0
 public static function LoadNewest($amount, $page)
 {
     $result = array();
     $page = $amount * $page;
     if ($stmt = Database::GetLink()->prepare('SELECT `recipe_id`, `picture_id`, `user_id`, `type_id`, `recipe_title`, `recipe_description`, `disabled` FROM `Recipe` LIMIT ?,?;')) {
         $stmt->bindParam(1, $page, PDO::PARAM_INT);
         $stmt->bindParam(2, $amount, PDO::PARAM_INT);
         $stmt->execute();
         $stmt->bindColumn(1, $recipeId);
         $stmt->bindColumn(2, $pictureId);
         $stmt->bindColumn(3, $userId);
         $stmt->bindColumn(4, $typeId);
         $stmt->bindColumn(5, $title);
         $stmt->bindColumn(6, $description);
         $stmt->bindColumn(7, $disabled);
         while ($stmt->fetch()) {
             $recipe = new Recipe($recipeId);
             $recipe->_user = User::Load($userId);
             //if ($pictureId != null) { $recipe->_picture = Image::Load($pictureId); }
             //if ($typeId != null) { $recipe->_type = Recipe::GetTypeName($typeId); }
             $recipe->_title = $title;
             $recipe->_description = $description;
             $recipe->_disabled = $disabled;
             $result[] = $recipe;
         }
         $stmt->closeCursor();
     }
     if (empty($result)) {
         $result = false;
     }
     return $result;
 }
Пример #2
0
 public function sendResetPasswordEmail($emailOrUserId)
 {
     $user = new User();
     $user->Load("email = ?", array($emailOrUserId));
     if (empty($user->id)) {
         $user = new User();
         $user->Load("username = ?", array($emailOrUserId));
         if (empty($user->id)) {
             return false;
         }
     }
     $params = array();
     //$params['user'] = $user->first_name." ".$user->last_name;
     $params['url'] = CLIENT_BASE_URL;
     $newPassHash = array();
     $newPassHash["CLIENT_NAME"] = CLIENT_NAME;
     $newPassHash["oldpass"] = $user->password;
     $newPassHash["email"] = $user->email;
     $newPassHash["time"] = time();
     $json = json_encode($newPassHash);
     $encJson = AesCtr::encrypt($json, $user->password, 256);
     $encJson = urlencode($user->id . "-" . $encJson);
     $params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
     $emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
     $this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
     return true;
 }
 public function getLeaveDaysReadonly($req)
 {
     $leaveId = $req->leave_id;
     $leaveLogs = array();
     $employeeLeave = new EmployeeLeave();
     $employeeLeave->Load("id = ?", array($leaveId));
     $employee = $this->baseService->getElement('Employee', $employeeLeave->employee, null, true);
     //$rule = $this->getLeaveRule($employee, $employeeLeave->leave_type);
     $currentLeavePeriodResp = $this->getCurrentLeavePeriod($employeeLeave->date_start, $employeeLeave->date_end);
     if ($currentLeavePeriodResp->getStatus() != IceResponse::SUCCESS) {
         return new IceResponse(IceResponse::ERROR, $currentLeavePeriodResp->getData());
     } else {
         $currentLeavePeriod = $currentLeavePeriodResp->getData();
     }
     $leaveMatrix = $this->getAvailableLeaveMatrixForEmployeeLeaveType($employee, $currentLeavePeriod, $employeeLeave->leave_type);
     $leaves = array();
     $leaves['totalLeaves'] = floatval($leaveMatrix[0]);
     $leaves['pendingLeaves'] = floatval($leaveMatrix[1]);
     $leaves['approvedLeaves'] = floatval($leaveMatrix[2]);
     $leaves['rejectedLeaves'] = floatval($leaveMatrix[3]);
     $leaves['cancelRequestedLeaves'] = floatval($leaveMatrix[4]);
     $leaves['cancelledLeaves'] = floatval($leaveMatrix[5]);
     $leaves['availableLeaves'] = $leaves['totalLeaves'] - $leaves['pendingLeaves'] - $leaves['approvedLeaves'] - $leaves['cancelRequestedLeaves'];
     $leaves['attachment'] = $employeeLeave->attachment;
     $employeeLeaveDay = new EmployeeLeaveDay();
     $days = $employeeLeaveDay->Find("employee_leave = ?", array($leaveId));
     $employeeLeaveLog = new EmployeeLeaveLog();
     $logsTemp = $employeeLeaveLog->Find("employee_leave = ? order by created", array($leaveId));
     foreach ($logsTemp as $empLeaveLog) {
         $t = array();
         $t['time'] = $empLeaveLog->created;
         $t['status_from'] = $empLeaveLog->status_from;
         $t['status_to'] = $empLeaveLog->status_to;
         $t['time'] = $empLeaveLog->created;
         $userName = null;
         if (!empty($empLeaveLog->user_id)) {
             $lgUser = new User();
             $lgUser->Load("id = ?", array($empLeaveLog->user_id));
             if ($lgUser->id == $empLeaveLog->user_id) {
                 if (!empty($lgUser->employee)) {
                     $lgEmployee = new Employee();
                     $lgEmployee->Load("id = ?", array($lgUser->employee));
                     $userName = $lgEmployee->first_name . " " . $lgEmployee->last_name;
                 } else {
                     $userName = $lgUser->userName;
                 }
             }
         }
         if (!empty($userName)) {
             $t['note'] = $empLeaveLog->data . " (by: " . $userName . ")";
         } else {
             $t['note'] = $empLeaveLog->data;
         }
         $leaveLogs[] = $t;
     }
     return new IceResponse(IceResponse::SUCCESS, array($days, $leaves, $leaveId, $employeeLeave, $leaveLogs));
 }
Пример #4
0
 public function saveUser($req)
 {
     $profileVar = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
     $profileClass = ucfirst(SIGN_IN_ELEMENT_MAPPING_FIELD_NAME);
     if ($this->user->user_level == 'Admin') {
         $user = new User();
         $user->Load("email = ?", array($req->email));
         if ($user->email == $req->email) {
             return new IceResponse(IceResponse::ERROR, "User with same email already exists");
         }
         $user->Load("username = ?", array($req->username));
         if ($user->username == $req->username) {
             return new IceResponse(IceResponse::ERROR, "User with same username already exists");
         }
         $user = new User();
         $user->email = $req->email;
         $user->username = $req->username;
         $password = $this->generateRandomString(6);
         $user->password = md5($password);
         $user->profile = empty($req->profile) || $req->profile == "NULL" ? NULL : $req->profile;
         $user->user_level = $req->user_level;
         $user->last_login = date("Y-m-d H:i:s");
         $user->last_update = date("Y-m-d H:i:s");
         $user->created = date("Y-m-d H:i:s");
         $profile = null;
         if (!empty($user->profile)) {
             $profile = $this->baseService->getElement($profileClass, $user->profile, null, true);
         }
         $ok = $user->Save();
         if (!$ok) {
             LogManager::getInstance()->info($user->ErrorMsg() . "|" . json_encode($user));
             return new IceResponse(IceResponse::ERROR, "Error occured while saving the user");
         }
         $user->password = "";
         $user = $this->baseService->cleanUpAdoDB($user);
         if (!empty($this->emailSender)) {
             $usersEmailSender = new UsersEmailSender($this->emailSender, $this);
             $usersEmailSender->sendWelcomeUserEmail($user, $password, $profile);
         }
         return new IceResponse(IceResponse::SUCCESS, $user);
     }
     return new IceResponse(IceResponse::ERROR, "Not Allowed");
 }
Пример #5
0
 public function saveUser($req)
 {
     if ($this->user->user_level == 'Admin') {
         $user = new User();
         $user->Load("email = ?", array($req->email));
         if ($user->email == $req->email) {
             return new IceResponse(IceResponse::ERROR, "User with same email already exists");
         }
         $user->Load("username = ?", array($req->username));
         if ($user->username == $req->username) {
             return new IceResponse(IceResponse::ERROR, "User with same username already exists");
         }
         $user = new User();
         $user->email = $req->email;
         $user->username = $req->username;
         $password = $this->generateRandomString(6);
         $user->password = md5($password);
         $user->employee = empty($req->employee) || $req->employee == "NULL" ? NULL : $req->employee;
         $user->user_level = $req->user_level;
         $user->last_login = date("Y-m-d H:i:s");
         $user->last_update = date("Y-m-d H:i:s");
         $user->created = date("Y-m-d H:i:s");
         $employee = null;
         if (!empty($user->employee)) {
             $employee = $this->baseService->getElement('Employee', $user->employee, null, true);
         }
         $ok = $user->Save();
         if (!$ok) {
             error_log($user->ErrorMsg() . "|" . json_encode($user));
             return new IceResponse(IceResponse::ERROR, "Error occured while saving the user");
         }
         $user->password = "";
         $user = $this->baseService->cleanUpAdoDB($user);
         if (!empty($this->emailSender)) {
             $usersEmailSender = new UsersEmailSender($this->emailSender, $this);
             $usersEmailSender->sendWelcomeUserEmail($user, $password, $employee);
         }
         return new IceResponse(IceResponse::SUCCESS, $user);
     }
     return new IceResponse(IceResponse::ERROR, "Not Allowed");
 }
Пример #6
0
 public function init()
 {
     if (SettingsManager::getInstance()->getSetting("Api: REST Api Enabled") == "1") {
         $user = BaseService::getInstance()->getCurrentUser();
         $dbUser = new User();
         $dbUser->Load("id = ?", array($user->id));
         $resp = RestApiManager::getInstance()->getAccessTokenForUser($dbUser);
         if ($resp->getStatus() != IceResponse::SUCCESS) {
             LogManager::getInstance()->error("Error occured while creating REST Api acces token for " . $user->username);
         }
     }
 }
Пример #7
0
 private function validateAccessTokenInner($accessToken)
 {
     $accessTokenTemp = AesCtr::decrypt($accessToken, APP_SEC, 256);
     $parts = explode("|", $accessTokenTemp);
     $user = new User();
     $user->Load("id = ?", array($parts[0]));
     if (empty($user->id) || $user->id != $parts[0] || empty($parts[0])) {
         return new IceResponse(IceResponse::ERROR, -1);
     }
     $accessToken = AesCtr::decrypt($parts[1], $user->password, 256);
     $data = json_decode($accessToken, true);
     if ($data['userId'] == $user->id) {
         return new IceResponse(IceResponse::SUCCESS, true);
     }
     return new IceResponse(IceResponse::ERROR, false);
 }
Пример #8
0
 public function Register($params)
 {
     $user = User::Load($params['login']);
     $saved = false;
     if ($user) {
         $user->Set($params);
         $saved = $user->Save();
     } else {
         $user = User::Add($params);
         if ($user) {
             $saved = true;
         }
     }
     if ($saved) {
         header('Location: /Login/UserView/login/' . $user->login, TRUE, 307);
     } else {
         header('Location: /Login/RegisterForm/', TRUE, 307);
     }
 }
Пример #9
0
 protected function createNewUsers()
 {
     $profileVar = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
     $profileClass = ucfirst(SIGN_IN_ELEMENT_MAPPING_FIELD_NAME);
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->user_level = 'Manager';
     $user->Save();
     $this->usersArray[$user->username] = $user;
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->user_level = 'Profile';
     $user->Save();
     $this->usersArray[$user->username] = $user;
     $user = new User();
     $user->Load("username = ?", array('admin'));
     $this->usersArray[$user->username] = $user;
 }
Пример #10
0
<?php

if (isset($_POST["txtUserName"])) {
    $user_name = trim($_POST["txtUserName"]);
    $password = $_POST["txtPassword"];
    $user = null;
    try {
        DBConnection::Connect();
        ${$user} = User::Load($user_name, $password);
        DBConnection::Close();
    } catch (Exception $ex) {
    }
    if ($user != null) {
        User::SetCookie();
        header("Location: /");
        exit;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" type="text/css" href="css/login.css?v=0.0.1" />
		<script type="text/javascript" src="../js/jquery-2.1.3.min.js"></script>
		<script type="text/javascript" src="js/login.js"></script>
	</head>
	<body>
		<form name="frmLogin" method="post">
			<?php 
// TODO: Make sucide because of using tables to orgenize the page, instead of divs and css
Пример #11
0
 /**
  * Reload this User from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved User object.');
     }
     // Reload the Object
     $objReloaded = User::Load($this->intId);
     // Update $this's local variables to match
     $this->strNick = $objReloaded->strNick;
     $this->strPassword = $objReloaded->strPassword;
     $this->strEmail = $objReloaded->strEmail;
     $this->strStatus = $objReloaded->strStatus;
     $this->dttCreatedAt = $objReloaded->dttCreatedAt;
     $this->strActivationKey = $objReloaded->strActivationKey;
     $this->dttActivatedAt = $objReloaded->dttActivatedAt;
     $this->dttLastseenAt = $objReloaded->dttLastseenAt;
     $this->strRealname = $objReloaded->strRealname;
     $this->strAddress = $objReloaded->strAddress;
     $this->strState = $objReloaded->strState;
     $this->strZip = $objReloaded->strZip;
     $this->intFbinCount = $objReloaded->intFbinCount;
     $this->intFbinTotal = $objReloaded->intFbinTotal;
     $this->intFboutCount = $objReloaded->intFboutCount;
     $this->intFboutTotal = $objReloaded->intFboutTotal;
 }
<?php

/**
This script creates a table named Users with following details
* HASH key = client
* RANGE Key = userId
* Global secondary index = email
*/
include dirname(__FILE__) . "/../include.inc.php";
include dirname(__FILE__) . "/models.php";
include dirname(__FILE__) . "/configure.php";
$user = new User();
$user->client = 'Vocanic';
$user->email = "*****@*****.**";
$user->password = "******";
$user->name = "User " . rand();
$user->location = "SL";
$user->time = 100;
$user->Save();
$user1 = new User();
$ok = $user1->Load(array($user->client, $user->userId), true);
echo "Newly created user  = "******"\r\n";
Пример #13
0
<?php

interface IUser
{
    function getName();
}
class User implements IUser
{
    public static function Load($id)
    {
        return new User($id);
    }
    public static function Create()
    {
        return new User(null);
    }
    public function __construct($id)
    {
    }
    public function getName()
    {
        return "Jack";
    }
}
$uo = User::Load(1);
echo $uo->getName() . "\n";
Пример #14
0
 public static function loadFromUsername($username)
 {
     $user = new User();
     $user->Load("username ='******'");
     return $user;
 }
Пример #15
0
     readfile($fileName);
     exit;
 } else {
     if ($action == 'rsp') {
         // linked clicked from password change email
         $user = new User();
         if (!empty($_REQUEST['key'])) {
             $arr = explode("-", $_REQUEST['key']);
             $userId = $arr[0];
             $keyArr = array_shift($arr);
             if (count($keyArr) > 1) {
                 $key = implode("-", $arr);
             } else {
                 $key = $arr[0];
             }
             $user->Load("id = ?", array($userId));
             if (!empty($user->id)) {
                 LogManager::getInstance()->info("Key : " . $key);
                 $data = AesCtr::decrypt($key, $user->password, 256);
                 if (empty($data)) {
                     $ret['status'] = "ERROR";
                     $ret['message'] = "Invalid Key for changing password, error decrypting data";
                 } else {
                     $data = json_decode($data, true);
                     if ($data['CLIENT_NAME'] != CLIENT_NAME || $data['email'] != $user->email) {
                         $ret['status'] = "ERROR";
                         $ret['message'] = "Invalid Key for changing password, keys do not match";
                     } else {
                         if (empty($_REQUEST['now'])) {
                             LogManager::getInstance()->info("now not defined");
                             header("Location:" . CLIENT_BASE_URL . "login.php?cp=1&key=" . $_REQUEST['key']);
Пример #16
0
 public static function GetMapsForRerunRequest()
 {
     if (USE_3DRERUN == "1") {
         $maps = DataAccess::GetAllMaps();
         $ret = array();
         foreach ($maps as $map) {
             if ((is_null($map->RerunID) || $map->RerunID == 0) && $map->RerunTries < RERUN_MAX_TRIES && $map->IsGeocoded) {
                 $user = new User();
                 $user->Load($map->UserID);
                 $ret[] = $map->ID . ";" . $user->Username;
             }
         }
         if (count($ret) > 0) {
             return implode(",", $ret);
         } else {
             return null;
         }
     }
 }
Пример #17
0
<?php

include "include.common.php";
include "server.includes.inc.php";
if (empty($user)) {
    if (!empty($_REQUEST['username']) && !empty($_REQUEST['password'])) {
        $suser = null;
        $ssoUserLoaded = false;
        include 'login.com.inc.php';
        if (empty($suser)) {
            $suser = new User();
            $suser->Load("(username = ? or email = ?) and password = ?", array($_REQUEST['username'], $_REQUEST['username'], md5($_REQUEST['password'])));
        }
        if ($suser->password == md5($_REQUEST['password']) || $ssoUserLoaded) {
            $user = $suser;
            saveSessionObject('user', $user);
            $suser->last_login = date("Y-m-d H:i:s");
            $suser->Save();
            if (!$ssoUserLoaded && !empty($baseService->auditManager)) {
                $baseService->auditManager->user = $user;
                $baseService->audit(IceConstants::AUDIT_AUTHENTICATION, "User Login");
            }
            if ($user->user_level == "Admin") {
                header("Location:" . CLIENT_BASE_URL . "?g=admin&n=dashboard&m=admin_Admin");
            } else {
                header("Location:" . CLIENT_BASE_URL . "?g=modules&n=dashboard&m=module_Personal_Information");
            }
        } else {
            header("Location:" . CLIENT_BASE_URL . "login.php?f=1");
        }
    }
Пример #18
0
     $message = $success ? array(Config::Get('success.created')) : Error::GetAll();
     break;
 case 'admin_edit':
     $user = new User();
     $user->Load(array('id' => $_POST['user_id']));
     $user->ChangeSettings($_POST);
     $success = Error::HasErrors() ? false : true;
     if (!empty($_POST['password']) || !empty($_POST['cpassword'])) {
         $success = $success && $user->ChangePassword($_POST);
     }
     $message = $success ? array(Config::Get('success.saved')) : Error::GetAll();
     $data = array('email' => $user->Get('email'), 'username' => $user->Get('username'));
     break;
 case 'admin_delete':
     $user = new User();
     if ($user->Load(array('id' => $_POST['user_id']))) {
         $success = $user->Delete();
     } else {
         Error::Set('user', 'usernotfound');
     }
     $message = $success ? array(Config::Get('success.saved')) : Error::GetAll();
     break;
 case 'admin_compose':
     $validator = new Validate();
     $success = $validator->AddValue('email', $_POST['email'])->AddPattern('email')->Check();
     $success = $success && Email::SendEmail($_POST['email'], $_POST['subject'], $_POST['message']);
     $message = $success ? array(Config::Get('success.sent')) : Error::GetAll();
     break;
 default:
     $message = array(Config::Get('unexpectederror'));
     break;
Пример #19
0
 public static function LoadComments($id)
 {
     $comments = array();
     $search = $id . '%%';
     if ($stmt = Database::GetLink()->prepare('SELECT `comment_id`, `user_id`, `comment_path`, `comment_contents`, `sent_at` FROM `Comment` WHERE `comment_path` LIKE ? ORDER BY `comment_path`, `sent_at` ASC;')) {
         $stmt->bindParam(1, $search, PDO::PARAM_STR, 255);
         $stmt->execute();
         $stmt->bindColumn(1, $commentid);
         $stmt->bindColumn(2, $userid);
         $stmt->bindColumn(3, $path);
         $stmt->bindColumn(4, $contents);
         $stmt->bindColumn(5, $timestamp);
         while ($stmt->fetch()) {
             $comment = new Comment($commentid);
             $comment->_user = User::Load($userid);
             $comment->_contents = $contents;
             $comment->_timestamp = $timestamp;
             $GLOBALS['COMMENTS'][$commentid] = $comment;
             if ($path == $id) {
                 $comments[] = $GLOBALS['COMMENTS'][$commentid];
             } else {
                 $parts = explode('>', $path);
                 $lastid = end($parts);
                 if (is_numeric($lastid)) {
                     $lastid = intval($lastid);
                     if (array_key_exists($lastid, $GLOBALS['COMMENTS'])) {
                         $parent = $GLOBALS['COMMENTS'][$lastid];
                         $parent->_comments[] = $comment;
                     }
                 }
             }
         }
         $stmt->closeCursor();
         return $comments;
     }
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this UserMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing User object creation - defaults to CreateOrEdit
  * @return UserMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objUser = User::Load($intId);
         // User was found -- return it!
         if ($objUser) {
             return new UserMetaControl($objParentObject, $objUser);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a User object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new UserMetaControl($objParentObject, new User());
 }
Пример #21
0
<?php

require_once '../config/init.php';
if (isset($_GET['id'])) {
    $user = new User();
    if (!$user->Load(array('id' => $_GET['id']))) {
        Error::Set('user', 'usernotfound');
    }
} else {
    Error::Set('user', 'usernotfound');
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	</head>
	<body style="text-align:center;margin:auto;width:300px;">
		<?php 
if (Error::HasErrors()) {
    ?>
			<div class="message-box"> <!--  add your error class here -->
				<ul><li><?php 
    echo Error::GetFirst();
    ?>
</li></ul>
			</div>
		<?php 
} else {
    ?>
Пример #22
0
$id_hostname = @gethostbyaddr($id_ip_address);
if ($id_hostname === $id_ip_address) {
    $id_hostname = false;
}
$ban = GetBanFromUID($_GET['uid']);
if ($ban != array()) {
    $banned = true;
}
// Fetch number of topics and replies.
$id_num_topics = DB::GetOne("SELECT count(*) FROM {P}Topics WHERE author = {$uid}");
$id_num_replies = DB::GetOne("SELECT count(*) FROM {P}Replies WHERE author = {$uid}");
// Now print everything.
$page_title = 'Profile of poster ' . $_GET['uid'];
dummy_form();
$usr = new User($_GET['UID']);
$usr->Load();
echo '<p><b>' . $usr->Level . '</b>. First seen <strong class="help" title="' . format_date($id_first_seen) . '">' . calculate_age($id_first_seen) . ' ago</strong> using the IP address <strong><a href="/IP_address/' . $id_ip_address . '">' . $id_ip_address . '</a></strong> (';
//If there's a valid host name ...
if ($id_hostname) {
    echo 'host name <strong>' . $id_hostname . '</strong>';
} else {
    echo 'no valid host name';
}
echo '), has started <strong>' . $id_num_topics . '</strong> existing topic' . ($id_num_topics == 1 ? '' : 's') . ' and posted <strong>' . $id_num_replies . '</strong> existing repl' . ($id_num_replies == 1 ? 'y' : 'ies') . '.</p>';
?>
<?if($banned):?>
	<p>This poster is currently <strong>banned</strong> until <?php 
echo format_date($ban['expiry']);
?>
 for the following reason:<br /><blockquote><?php 
echo $ban['reason'];
Пример #23
0
 public function act_edit_user()
 {
     // var_dump($_POST);
     include_once APPROOT . 'inc/lib_form.inc';
     include_once APPROOT . 'inc/lib_form_util.inc';
     include_once APPROOT . 'inc/lib_validate.inc';
     include_once APPROOT . 'inc//security/lib_auth.inc';
     include_once APPROOT . 'mod/admin/lib_user.inc';
     $user_form = user_get_form();
     unset($user_form['username']);
     unset($user_form['role']);
     unset($user_form['status']);
     unset($user_form['password1']);
     unset($user_form['password2']);
     $this->user_form = $user_form;
     //$user_form['username']['type'] = 'hidden';
     //$user_form['username']['extra_opts']['value'] = $_SESSION['username'];
     if (isset($_POST['save'])) {
         $valide = true;
         $username = $_SESSION['username'];
         $firstName = $_POST['first_name'];
         $lastName = $_POST['last_name'];
         $organization = $_POST['organization'];
         $designation = $_POST['designation'];
         $email = $_POST['email'];
         $address = $_POST['address'];
         $locale = $_POST['locale'];
         if (isset($email) && $email != '' && !shn_valid_email($email)) {
             //email not valide
             $user_form['email']['extra_opts'] = array();
             $user_form['email']['extra_opts']['error'] = array();
             $user_form['email']['extra_opts']['error'][] = _t("INVALID_EMAIL");
             $valide = false;
         }
         $this->user_form = $user_form;
         if ($valide == true) {
             $user = new User();
             $user = UserHelper::loadFromUsername($username);
             //$user->loadUserProfile();
             //$user->role = $role;
             //$user->status =  $status;
             $cfg = array();
             if (!empty($user->config)) {
                 $cfg = @json_decode($user->config, true);
             }
             $cfg['locale'] = $locale;
             $user->config = json_encode($cfg);
             $user->Save();
             $userProfile = UserProfileHelper::loadFromUsername($username);
             $userProfile->username = $username;
             $userProfile->first_name = $firstName;
             $userProfile->last_name = $lastName;
             $userProfile->organization = $organization;
             $userProfile->designation = $designation;
             $userProfile->email = $email;
             $userProfile->address = $address;
             $userProfile->Save();
             set_redirect_header('home', 'edit_user');
         }
     }
     if (isset($_SESSION['username'])) {
         $user = new User();
         $userProfile = new UserProfile();
         $username = $_SESSION['username'];
         $user->Load("username='******'");
         $userProfile->Load("username='******'");
         //$user_form['username']['extra_opts']['value'] = $user->getUserName();
         //$user_form['password1'] = null;
         //$user_form['password2'] = null;
         $user_form['first_name']['extra_opts']['value'] = $userProfile->getFirstName();
         $user_form['last_name']['extra_opts']['value'] = $userProfile->getLastName();
         $user_form['organization']['extra_opts']['value'] = $userProfile->getOrganization();
         $user_form['designation']['extra_opts']['value'] = $userProfile->getDesignation();
         $user_form['email']['extra_opts']['value'] = $userProfile->getEmail();
         $user_form['address']['extra_opts']['value'] = $userProfile->getAddress();
         //$user_form['role']['extra_opts']['value'] = $user->getUserType();
         //$user_form['status']['extra_opts']['value'] = $user->status;
         if (!empty($user->config)) {
             $cfg = @json_decode($user->config, true);
             if ($cfg['locale']) {
                 $user_form['locale']['extra_opts']['value'] = $cfg['locale'];
             }
         }
         $this->user_form = $user_form;
     }
     $this->username = $username;
 }
Пример #24
0
<?php

if (!defined('ADMIN')) {
    die("Access denied!");
}
$compose_user = new User();
if (isset($_GET['id']) && $compose_user->Load(array('id' => $_GET['id']))) {
    $email = $compose_user->Get('email');
} else {
    $email = '';
}
?>
  	<form class="ajaxform" method="POST" action="">
 		<h2>Compose an email</h2>
		<div class="message-box"></div>
		To:
		<input type="text" name="email" value="<?php 
echo $email;
?>
"><br>
		Subject:
		<input type="text" name="subject"><br>
		Message:
		<textarea name="message"></textarea><br>
		<input type="hidden" name="action" value="admin_compose">
		<button type="submit" name="sendemail">SEND EMAIL</button>
	</form>
Пример #25
0
				$_SESSION['notice'].='<li>'.$_POST['add_sysop'].' added as a '.ADMIN_NAME.'.</li>';
			}
			if(!empty($_POST['add_mod']))
			{
				if($lvl<100) die('No.');
				DB::Execute('UPDATE {P}UserSettings SET usrFlags=usrFlags|'.PERMISSION_MOD.' WHERE usrID='.DB::Q($_POST['add_mod']));
				$_SESSION['notice'].='<li>'.$_POST['add_mod'].' added as a '.MOD_NAME.'.</li>';
			}
			if(!empty($_POST['revoke']) && is_array($_POST['revoke']) && count($_POST['revoke'])>0)
			{
				if($lvl<999) die('No.');
				$c=0;
				foreach($_POST['revoke'] as $modid)
				{
					$u=new User($modid);
					$u->Load();
					if($u->getMACLevel()>=$lvl) 
						die('No.');
					$u->Flags&=~PERMISSION_MOD; // Remove mod flag
					$u->Flags&=~PERMISSION_SYSOP; // Remove admin flag
					$u->Save();
					$c++;
				}
				$_SESSION['notice'].='<li>'.$c.' power users revoked.</li>';
			}
			$_SESSION['notice']="<ul>{$_SESSION['notice']}</ul>";
		}
		$page_title = 'Manage Users';

		$mods=new TablePrinter('tblModerators');
		$mods->DefineColumns(array('&nbsp;','UID','Last Action'),'Last Action');
Пример #26
0
<?php

if (!defined('ADMIN')) {
    die("Access denied!");
}
$edit_user = new User();
if (isset($_GET['id']) && $edit_user->Load(array('id' => $_GET['id']))) {
    ?>
	<form class="ajaxform" method="POST" action="">
		<h2>Edit an user</h2>
		<div class="message-box"></div>
		Username:
		<input type="text" name="username" value="<?php 
    echo $edit_user->Get('username');
    ?>
"><br>
		Email:
		<input type="text" name="email" value="<?php 
    echo $edit_user->Get('email');
    ?>
"><br>
		User type:
		<select name="user_type">
			<option value="user" <?php 
    echo $edit_user->Get('user_type') == 'user' ? 'selected' : '';
    ?>
>user</option>
			<option value="admin" <?php 
    echo $edit_user->Get('user_type') == 'admin' ? 'selected' : '';
    ?>
>admin</option>
Пример #27
0
 static function ConnectTwitter($user_data)
 {
     $user = new User();
     $result = $user->Load(array('social_id' => $user_data['id']));
     if ($result) {
         Session::Set("current_user", $user);
         return true;
     } else {
         if (Session::Get('twitter_user')) {
             $img = str_replace("_normal", "", $user_data['picture']);
             $data = array('avatar' => $img, 'email' => $user_data['email'], 'username' => $user_data['username'], 'fullname' => $user_data['fullname'], 'location' => $user_data['location'], 'about' => $user_data['about'], 'social_id' => $user_data['id'], 'social_type' => 'twitter', 'activation_state' => '1', 'user_type' => 'user');
             $user = User::AddUser($data);
             if ($user) {
                 $user->Load(array('social_id' => $user_data['id']));
                 unset($_SESSION['twitter_user']);
                 Session::Set('current_user', $user);
                 header('Location: ' . Config::Get('base_url') . 'index.php');
                 return true;
             }
         } else {
             Session::Set('twitter_user', $user_data);
             header('Location: ' . Config::Get('base_url') . 'auth/twitteremail.php');
         }
     }
     return false;
 }