protected function beforeAction($action)
 {
     $controller = Yii::app()->controller->id;
     $action = Yii::app()->controller->action->id;
     if ($controller == "site" && $action == "login") {
         return TRUE;
     }
     if ($controller == "site" && $action == "logout") {
         return TRUE;
     }
     if (Yii::app()->user == NULL) {
         $this->redirect(Yii::app()->request->baseUrl . "/site/login");
     } else {
         if (Yii::app()->user->getId() != NULL) {
             $log = new UserLog();
             $log->time = date("Y-m-d H:i:s");
             $log->user_id = Yii::app()->user->id;
             $log->user_level_id = Yii::app()->user->level_id;
             $log->path = $_SERVER["REQUEST_URI"];
             $log->data = json_encode($_POST);
             $log->is_ajax = 0;
             if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 $log->is_ajax = 1;
             }
             $log->save();
             return TRUE;
         } else {
             $this->redirect(Yii::app()->request->baseUrl . "/site/login");
         }
     }
 }
Ejemplo n.º 2
0
 public static function afterLogin($e)
 {
     $ip = \Yii::$app->request->getUserIP();
     $log = UserLog::findByIp($ip);
     if (!$log) {
         $log = new UserLog();
         $log->ip = $ip;
     } else {
         $log->logincount += 1;
     }
     $log->userAgent = \Yii::$app->request->getUserAgent();
     $log->lastvisit = time();
     $log->save(false);
 }
Ejemplo n.º 3
0
 public static function createUserLog($params)
 {
     $resultInfo = array();
     $userLog = new UserLog();
     $userLog->attributes = $params;
     if (!$userLog->save()) {
         $resultInfo['status'] = CommonService::$ApiResult['FAIL'];
         $resultInfo['detail'] = $userLog->getErrors();
     } else {
         $resultInfo['status'] = CommonService::$ApiResult['SUCCESS'];
         $resultInfo['detail'] = array('id' => $userLog->id);
     }
     return $resultInfo;
 }
 function setAuthed($bool)
 {
     $this->blAuthed = $bool;
     if ($bool) {
         UserLog::addEntry($this->blid, $this->name);
     }
 }
Ejemplo n.º 5
0
 public function show()
 {
     if ($this->params()->name) {
         $this->user = User::where(['name' => $this->params()->name])->first();
     } else {
         $this->user = User::find($this->params()->id);
     }
     if (!$this->user) {
         $this->redirectTo("/404");
     } else {
         if ($this->user->id == current_user()->id) {
             $this->set_title('My profile');
         } else {
             $this->set_title($this->user->name . "'s profile");
         }
     }
     if (current_user()->is_mod_or_higher()) {
         # RP: Missing feature.
         // $this->user_ips = $this->user->user_logs->order('created_at DESC').pluck('ip_addr').uniq
         $this->user_ips = array_unique(UserLog::where(['user_id' => $this->user->id])->order('created_at DESC')->take()->getAttributes('ip_addr'));
     }
     $tag_types = CONFIG()->tag_types;
     foreach (array_keys($tag_types) as $k) {
         if (!preg_match('/^[A-Z]/', $k) || $k == 'General' || $k == 'Faults') {
             unset($tag_types[$k]);
         }
     }
     $this->tag_types = $tag_types;
     $this->respondTo(array('html'));
 }
Ejemplo n.º 6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = UserLog::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 7
0
 public function saveUserLog($unique_id, $session_id, $user_id, $employee_id, $login_time = null, $logout_time = null)
 {
     $model = new UserLog();
     $model->unique_id = $unique_id;
     $model->user_id = $user_id;
     $model->sessoin_id = $session_id;
     $model->employee_id = $employee_id;
     $model->login_time = $login_time;
     $model->logout_time = $logout_time;
     $model->save();
 }
Ejemplo n.º 8
0
 public function log($ip)
 {
     return Rails::cache()->fetch(['type' => 'user_logs', 'id' => $this->id, 'ip' => $ip], ['expires_in' => '10 minutes'], function () use($ip) {
         Rails::cache()->fetch(['type' => 'user_logs', 'id' => 'all'], ['expires_in' => '1 day'], function () {
             # RP: Missing relation method "deleteAll()"
             return UserLog::where('created_at < ?', date('Y-m-d 0:0:0', strtotime('-3 days')))->take()->each('destroy');
         });
         # RP: Missing feature.
         $log_entry = UserLog::where(['ip_addr' => $ip, 'user_id' => $this->id])->firstOrInitialize();
         $log_entry->created_at = date('Y-m-d H:i:s');
         return $log_entry->save();
     });
 }
Ejemplo n.º 9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     if (!Auth::check()) {
         // Custom for required fields.
         if (empty(Input::get('username')) || empty(Input::get('password'))) {
             Session::flash('message', 'Please input your credentials.');
             return Redirect::to('api');
         } else {
             if (Auth::attempt(array('username' => Input::get('username'), 'password' => Input::get('password')))) {
                 // Save to user_log table
                 $id = Auth::id();
                 $log = new UserLog();
                 $log->user_id = $id;
                 $log->login = date('Y-m-d H:i:s');
                 $log->save();
                 // End
                 Session::put('log_id', $log->id);
                 $option = Input::get('option');
                 if ($option == 'crud') {
                     return Redirect::to('crud');
                 } else {
                     return Redirect::to('api');
                 }
             } else {
                 Session::flash('message', 'Invalid credentials.');
                 return Redirect::back();
             }
         }
     } else {
         if (!$this->user->isValid($input = Input::all())) {
             return Redirect::back()->withInput()->withErrors($this->user->error);
         } else {
             $this->user->create($input);
             Session::flash('message', 'Successfully added user.');
             return Redirect::to("api");
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //City
     City::created(function ($city) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]);
     });
     City::updated(function ($city) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]);
     });
     City::deleted(function ($city) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]);
     });
     //Country
     Country::created(function ($country) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]);
     });
     Country::updated(function ($country) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]);
     });
     Country::deleted(function ($country) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]);
     });
     //Region
     Region::created(function ($region) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]);
     });
     Region::updated(function ($region) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]);
     });
     Region::deleted(function ($region) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]);
     });
     //State
     State::created(function ($state) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]);
     });
     State::updated(function ($state) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]);
     });
     State::deleted(function ($state) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]);
     });
 }
Ejemplo n.º 11
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (strpos($this->username, "@")) {
         $user = RbacUser::model()->findByAttributes(array('user_email' => $this->username));
     } else {
         $user = RbacUser::model()->findByAttributes(array('user_name' => $this->username));
         $ph = new PasswordHash(Yii::app()->params['phpass']['iteration_count_log2'], Yii::app()->params['phpass']['portable_hashes']);
     }
     if ($user === null) {
         if (strpos($this->username, "@")) {
             $this->errorCode = self::ERROR_EMAIL_INVALID;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
     } elseif (!$ph->CheckPassword($this->password, $user->user_password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         //else if($user->status==0&&Yii::app()->getModule('user')->loginNotActiv==false)
         //	$this->errorCode=self::ERROR_STATUS_NOTACTIV;
     } elseif ($user->status == 0) {
         $this->errorCode = self::ERROR_STATUS_NOTACTIV;
     } else {
         $this->_id = $user->id;
         $this->username = $user->user_name;
         // title column as username
         $this->errorCode = self::ERROR_NONE;
         $employeeId = $user->employee_id;
         // Store employee ID in a session:
         //$this->setState('employeeid',$employeeId);
         Yii::app()->session['employeeid'] = $employeeId;
         Yii::app()->session['userid'] = $user->id;
         $employee = Employee::model()->findByPk($employeeId);
         Yii::app()->session['emp_fullname'] = $employee->first_name . ' ' . $employee->last_name;
         //Saving User Login & out timing
         Yii::app()->session['unique_id'] = uniqid();
         $login_time = Date('Y-m-d H:i:s');
         UserLog::model()->saveUserlog(Yii::app()->session['unique_id'], Yii::app()->session->sessionID, Yii::app()->session['userid'], $employeeId, $user->user_name, $login_time);
     }
     return !$this->errorCode;
 }
Ejemplo n.º 12
0
 /**
  * function ->delete ()
  */
 public function delete()
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = $this;
     if ($log = new UserLog()) {
         $log->username = $username;
         $log->action = "Delete ProductCategoryToProduct, id = {$model->id}";
         $log->created_at = $now;
         $log->type = 3;
         $log->is_success = 0;
         $log->save();
     }
     if (parent::delete()) {
         if ($log) {
             $log->is_success = 1;
             $log->save();
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 13
0
 public static function addEntry($blid, $username, $ip = null)
 {
     if (isset($ip)) {
         if (!UserLog::isRemoteVerified($blid, $username, $ip)) {
             return "auth.blockland.us verification failed";
         }
     }
     $db = new DatabaseManager();
     UserLog::verifyTable($db);
     $resource = $db->query("SELECT * FROM `user_log` WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     if ($resource->num_rows == 0) {
         $db->query("INSERT INTO `user_log` (`blid`, `firstseen`, `lastseen`, `username`) VALUES ('" . $db->sanitize($blid) . "', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '" . $db->sanitize($username) . "');");
     } else {
         $db->query("UPDATE `user_log` SET `lastseen` = CURRENT_TIMESTAMP WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     }
     //update username
     if ($user = UserManager::getFromBLID($blid)) {
         if ($username != $user->getUsername()) {
             $user->setUsername($username);
         }
     }
 }
Ejemplo n.º 14
0
 public function resetPassword()
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         $input = Input::all();
         $validator = Validator::make(array("username" => $input["username"], "new_password" => $input["new_password"], "new_password2" => $input["new_password2"], "root_password" => $input["root_password"]), array("username" => "required|alpha_dash|exists:tbl_user_accounts,username", "new_password" => "required|min:8", "new_password2" => "required|min:8", "root_password" => "required"));
         if ($validator->fails()) {
             Input::flash();
             return Redirect::to('accounts/passwordmanager')->with('message', $validator->messages()->first());
         } else {
             if (!Auth::attempt(array('username' => Session::get('username'), 'password' => $input['root_password']))) {
                 Input::flash();
                 return Redirect::to('accounts/passwordmanager')->with('message', "Invalid root password. Try again.");
             } else {
                 if ($input["new_password"] != $input["new_password2"]) {
                     Input::flash();
                     return Redirect::to('accounts/passwordmanager')->with('message', "New passwords didn't match. Try again.");
                 } else {
                     $user = User::where("username", "=", $input["username"])->first();
                     if ($user->user_type == "Root") {
                         Input::flash();
                         return Redirect::to('accounts/passwordmanager')->with('message', "Cannot reset password of root administrator accounts.");
                     }
                     $user->password = Hash::make(trim($input["new_password"]));
                     $user->save();
                     $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has reset the password of <strong>" . $user->username . "</strong>.";
                     //Log the changes made
                     $newLog = new UserLog();
                     $newLog->description = $desc;
                     $newLog->user_id = Session::get('user_id');
                     $newLog->type = "System";
                     $newLog->save();
                     return Redirect::to('accounts/passwordmanager')->with('success', "User <b>" . $input['username'] . "'s</b> password has been changed. ");
                 }
             }
         }
     } else {
         return Redirect::to('/');
     }
 }
 protected function beforeAction($action)
 {
     $controller = Yii::app()->controller->id;
     $action = Yii::app()->controller->action->id;
     if ($controller == "site" && $action == "login") {
         return TRUE;
     }
     if ($controller == "notFound") {
         return TRUE;
     }
     /*if(Yii::app()->user->level != NULL){
           $module = Module::model()->findByAttributes(array("controller"=>$controller));
           $hakAkses = HakAkses::model()->findByAttributes(array("module_id"=>$module->id, "user_level_id"=>Yii::app()->user->level));
           if($hakAkses == NULL){
               //throw new CHttpException(404, 'Halaman Tidak Ditemukan.');
               $this->redirect(Yii::app()->request->baseUrl . "/notFound/");
               return FALSE;
           }
           
       }*/
     if (Yii::app()->user == NULL) {
         $this->redirect(Yii::app()->request->baseUrl . "/site/login");
     } else {
         if (Yii::app()->user->getId() != NULL) {
             $log = new UserLog();
             $log->time = date("Y-m-d H:i:s");
             $log->user_id = Yii::app()->user->id;
             $log->user_level_id = Yii::app()->user->level_id;
             $log->path = $_SERVER["REQUEST_URI"];
             $log->data = json_encode($_POST);
             $log->is_ajax = 0;
             if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 $log->is_ajax = 1;
             }
             $log->save();
             return TRUE;
         } else {
             $this->redirect(Yii::app()->request->baseUrl . "/site/login");
         }
     }
 }
Ejemplo n.º 16
0
<?php

/*$_GET['aid'] = $_REQUEST['id'];
$comments = include(dirname(__DIR__) . "/../../../private/json/getPageCommentsWithUsers.php");
echo json_encode($comments, JSON_PRETTY_PRINT);*/
require_once dirname(__DIR__) . "/../../../private/class/AddonManager.php";
require_once dirname(__DIR__) . "/../../../private/class/CommentManager.php";
$aid = $_REQUEST['id'];
if (!isset($_REQUEST['page'])) {
    $page = 0;
} else {
    $page = $_REQUEST['page'];
}
$addonObject = AddonManager::getFromID($aid);
$ret = array();
$start = $page * 10;
$comments = CommentManager::getCommentIDsFromAddon($addonObject->getId(), $start, 10);
foreach ($comments as $comid) {
    $comment = CommentManager::getFromId($comid);
    $commento = new stdClass();
    $commento->id = $comment->getId();
    $commento->author = UserLog::getCurrentUsername($comment->getBLID());
    $commento->authorblid = $comment->getBlid();
    $text = str_replace("\r\n", "<br>", $comment->getComment());
    $text = str_replace("\n", "<br>", $text);
    $commento->text = $text;
    $commento->date = date("F j, g:i a", strtotime($comment->getTimeStamp()));
    $ret[] = $commento;
}
echo json_encode($ret, JSON_PRETTY_PRINT);
Ejemplo n.º 17
0
</a> <?php 
echo $ct == 1 ? "user" : "users";
?>
 are running Glass - which equates to <?php 
$nonglass = StatManager::getMasterServerStats()['users'];
$glass = sizeof(UserLog::getRecentlyActive());
$percentage = floor(100 / $nonglass * $glass);
if ($percentage > 100) {
    echo "<b>" . $percentage . "%</b> (how is this happening)";
} else {
    echo "<b>" . $percentage . "%</b>";
}
?>
		of Blockland as of this moment. Glass has <b>
		<?php 
echo $ct = UserLog::getUniqueCount();
?>
		</b>
        active <?php 
echo $ct == 1 ? "user" : "users";
?>
, with a total of <a href="stats/"><?php 
$web = StatManager::getAllAddonDownloads("web") + 0;
$ingame = StatManager::getAllAddonDownloads("ingame") + 0;
$updates = StatManager::getAllAddonDownloads("updates") + 0;
echo $web + $ingame;
?>
</b></a> downloads and <b><?php 
echo $updates;
?>
</b> updates.
Ejemplo n.º 18
0
 public function deleteAssets()
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         $ip = Input::get("ip_id");
         $hasDeletedAny = false;
         $noOfDeletedAssets = 0;
         foreach ($ip as $s) {
             $ip = IP::find($s);
             if (!$ip) {
                 continue;
             }
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted IP asset ( type: " . $ip->type . ") <strong>" . $ip->ip . "</strong>.";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
             $hasDeletedAny = true;
             $noOfDeletedAssets += 1;
             $ip->delete();
         }
         if ($hasDeletedAny) {
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted <strong>" . $noOfDeletedAssets . "</strong> IP asset(s).";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
         }
         return Redirect::to(Session::get("page"));
     } else {
         return Redirect::to("/");
     }
 }
Ejemplo n.º 19
0
 public function deleteSoftwareType($id)
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         if (!is_numeric($id) || !SoftwareType::find($id)) {
             return Redirect::to("settings/assets/softwaretypes");
         } else {
             if (count(SoftwareType::find($id)->softwareassets) > 0) {
                 return Redirect::to("settings/assets/softwaretypes");
             }
         }
         $softwareType = SoftwareType::find($id);
         $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted software type <strong>" . $softwareType->software_type . "</strong>.";
         //Log the changes made
         $newLog = new UserLog();
         $newLog->description = $desc;
         $newLog->user_id = Session::get('user_id');
         $newLog->type = "System";
         $newLog->save();
         $softwareType->delete();
         return Redirect::to("settings/assets/softwaretypes");
     } else {
         return Redirect::to("/");
     }
 }
Ejemplo n.º 20
0
 public function deleteAssets()
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         $assets = Input::get("asset_id");
         $hasDeletedAny = false;
         $noOfDeletedAssets = 0;
         foreach ($assets as $a) {
             $asset = Asset::where("id", "=", $a)->whereHas("classification", function ($query) {
                 $query->where("type", "=", "Network");
             })->first();
             if (!$asset) {
                 continue;
             }
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted network asset ( type: " . $asset->classification->name . ")  <strong>" . $asset->asset_tag . "</strong>, SN: <strong>" . $asset->serial_number . "</strong>.";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
             $hasDeletedAny = true;
             $noOfDeletedAssets += 1;
             $asset->delete();
         }
         if ($hasDeletedAny) {
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted <strong>" . $noOfDeletedAssets . "</strong> network asset(s).";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
         }
         return Redirect::to(Session::get("page"));
     } else {
         return Redirect::to("/");
     }
 }
Ejemplo n.º 21
0
    $board[1] = "Client Mods";
    $board[2] = "Server Mods";
    $board[3] = "Bricks";
    $board[4] = "Cosmetics";
    $board[5] = "Gamemodes";
    $board[6] = "Tools";
    $board[7] = "Weapons";
    $board[8] = "Colorsets";
    $board[9] = "Vehicles";
    $board[10] = "Bargain Bin";
    $board[11] = "Sounds";
    $o = new stdClass();
    $o->id = $ao->getId();
    $o->name = $ao->getName();
    $o->board = $board[$ao->getBoard()];
    $un = utf8_encode(UserLog::getCurrentUsername($ao->getManagerBLID()));
    if ($un === false) {
        $un = UserManager::getFromBLID($ao->getManagerBLID())->getUsername();
    }
    $o->author = $un;
    $ar[] = $o;
}
$dlg->uploads = $ar;
$ar = array();
foreach ($recentUpdates as $r) {
    $ao = $r->getAddon();
    if (!$ao->getApproved()) {
        continue;
    }
    if ($ao->getBoard() == 10) {
        // bargain bin
Ejemplo n.º 22
0
if (isset($_REQUEST['ident']) && $_REQUEST['ident'] != "") {
    $con = ClientConnection::loadFromIdentifier($_REQUEST['ident']);
    $ret = new stdClass();
    if (!is_object($con)) {
        $ret->status = "fail";
        error_log("Auth failed for ident " . $_REQUEST['ident']);
    } else {
        error_log("Auth pass for " . $_REQUEST['ident']);
        $ret->ident = $con->getIdentifier();
        $ret->blid = $con->getBLID();
        if ($ret->blid == 118256 || $ret->blid == 43364 || $ret->blid == 21186) {
            $ret->status = "barred";
            $json = json_encode($ret, JSON_PRETTY_PRINT);
            die($json);
        }
        $ret->username = iconv("ISO-8859-1", "UTF-8", UserLog::getCurrentUsername($ret->blid));
        error_log("Username is " . $ret->username);
        $ret->admin = false;
        $ret->mod = false;
        $user = UserManager::getFromBLID($ret->blid);
        if ($user !== false) {
            $ret->beta = false;
            if ($user->inGroup("Administrator")) {
                $ret->admin = true;
                $ret->mod = true;
                $ret->beta = true;
            } else {
                if ($user->inGroup("Moderator")) {
                    $ret->mod = true;
                    $ret->beta = true;
                }
Ejemplo n.º 23
0
 /**
  * function ->delete ()
  */
 public function delete()
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = $this;
     if ($log = new UserLog()) {
         $log->username = $username;
         $log->action = 'Delete';
         $log->object_class = 'GeneralInfoTranslation';
         $log->object_pk = $model->id;
         $log->created_at = $now;
         $log->is_success = 0;
         $log->save();
     }
     if (parent::delete()) {
         if ($log) {
             $log->is_success = 1;
             $log->save();
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 24
0
<?php

$tables_to_clear = array(User::table(), Customer::table(), Product::table(), Cart::table(), Address::table(), UserLog::table(), Account::table(), AccountHistory::table());
$db = Sdb::getDb();
foreach ($tables_to_clear as $table) {
    $db->exec("TRUNCATE TABLE {$table}");
}
if (_get('exit')) {
    echo '<script src="static/hide.js"></script>';
    echo '<div class="conclusion pass">All Clear!</div>';
    exit;
}
Ejemplo n.º 25
0
$aid = $_REQUEST['id'];
if (!isset($_REQUEST['page'])) {
    $page = 0;
} else {
    $page = $_REQUEST['page'];
}
$addonObject = AddonManager::getFromID($aid);
if (isset($_REQUEST['newcomment'])) {
    if ($con->isAuthed()) {
        CommentManager::submitComment($addonObject->getId(), $con->getBlid(), stripcslashes($_REQUEST['newcomment']));
    }
}
$res = new stdClass();
$res->status = "success";
$ret = array();
$start = $page * 10;
$comments = CommentManager::getCommentIDsFromAddon($addonObject->getId(), $start, 10, 1);
foreach ($comments as $comid) {
    $comment = CommentManager::getFromId($comid);
    $commento = new stdClass();
    $commento->id = $comment->getId();
    $commento->author = utf8_encode(UserLog::getCurrentUsername($comment->getBLID()));
    $commento->authorblid = $comment->getBlid();
    $text = str_replace("\r\n", "<br>", $comment->getComment());
    $text = str_replace("\n", "<br>", $text);
    $commento->text = utf8_encode($text);
    $commento->date = date("M jS Y, g:i A", strtotime($comment->getTimeStamp()));
    $ret[] = $commento;
}
$res->comments = $ret;
echo json_encode($res, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
 public function updateUserActivationByAdmin($user_id, $action)
 {
     if (strtolower($action) == 'activate') {
         $user = User::where("id", $user_id)->where('activated', 0)->first();
         if ($user) {
             $activation_code = $user->getActivationCode();
             $userService = new UserAccountService();
             $userService->activateUser($user, $activation_code, $auto_login = false);
         }
         $success_msg = trans('admin/manageMembers.memberlist_activated_suc_msg');
     } else {
         $user = User::where("id", $user_id)->first();
         $data_arr['activated'] = 0;
         User::where('id', $user_id)->update($data_arr);
         $success_msg = trans('admin/manageMembers.memberlist_deactivated_suc_msg');
     }
     // Add user log entry
     $data_arr['user_id'] = $user_id;
     $data_arr['added_by'] = getAuthUser()->id;
     $data_arr['date_added'] = date('Y-m-d H:i:s');
     $data_arr['log_message'] = $success_msg . " Added by: " . getAuthUser()->first_name . " On." . date('Y-m-d H:i:s');
     $userlog = new UserLog();
     $userlog->addNew($data_arr);
     return $success_msg;
 }
Ejemplo n.º 27
0
<?php

require_once dirname(__DIR__) . '/private/class/UserLog.php';
echo "Current: " . UserLog::getCurrentUsername($_GET['blid']);
if (isset($_GET['username'])) {
    UserLog::addEntry($_GET['blid'], $_GET['username'], $_SERVER['REMOTE_ADDR']);
}
Ejemplo n.º 28
0
 /**
  * Logs out the current user and redirect to homepage.
  */
 public function actionLogout()
 {
     UserLog::model()->saveUserLogOut(Yii::app()->session['unique_id'], Date('Y-m-d H:i:s'));
     Yii::app()->user->logout();
     $this->redirect(Yii::app()->homeUrl);
 }
Ejemplo n.º 29
0
    $failed = true;
}
?>
<div class="maincontainer">
<?php 
/*Ideas:
		- select avatar from some predetermined list
		- custom description
		- friends list
		- linking to steam
	*/
if ($failed) {
    echo "<h3>Uh-Oh</h3>";
    echo "<p>Whoever you're looking for either never existed or deleted their account.</p>";
} else {
    $history = UserLog::getHistory($userObject->getBLID());
    echo "<h3>" . htmlspecialchars($userObject->getName()) . "</h3>";
    echo "<p><b>Last Seen:</b> " . $history[0]->lastseen;
    echo "<br /><b>BL_ID:</b> " . $userObject->getBLID();
    echo "</p><hr />";
    echo "<a href=\"/addons/search.php?blid=" . htmlspecialchars($userObject->getBLID()) . "\"><b>Find Add-Ons by this user</b></a>";
    ?>
		<hr />
		<table style="width: 100%">
			<thead>
				<tr>
					<th style="width: 33%">Username</th><th>Last Seen</th><th>First Seen</th>
				</tr>
			</thead>
			<tbody>
				<?php 
Ejemplo n.º 30
0
 public function deleteEmployee()
 {
     if (Session::has('username') && Session::get('user_type') == "Root") {
         $employees = Input::get("employee_id");
         $hasDeletedAny = false;
         $noOfDeletedEmployees = 0;
         foreach ($employees as $e) {
             $employee = Employee::find($e);
             if (!$employee) {
                 continue;
             }
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted employee <strong>" . $employee->first_name . " " . $employee->last_name . " (Employee #: " . $employee->employee_number . ") </strong>.";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "Employees";
             $newLog->save();
             $hasDeletedAny = true;
             $noOfDeletedEmployees += 1;
             $employee->delete();
         }
         if ($hasDeletedAny) {
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted <strong>" . $noOfDeletedEmployees . "</strong> employee(s).";
             //Log the changes made
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "Employees";
             $newLog->save();
         }
         return Redirect::to(Session::get("page"));
     } else {
         return Redirect::to("/");
     }
 }