Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- UserSpice 4
- An Open Source PHP User Management System
- by the UserSpice Team at http://UserSpice.com
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- //Put your custom functions in this file and they will be automatically included.
- //bold("<br><br>custom helpers included");
- // Get Roles
- function getRoles($id, $opts = []){
- $db = DB::getInstance();
- $userQ = $db->query("SELECT * FROM user_permission_matches WHERE user_id = ? ORDER BY permission_id DESC",array($id));
- $c = $userQ->count();
- if($c > 0){
- $u = $userQ->first();
- echoPerm($u->permission_id);
- }
- }
- function echoPerm($id){
- $db = DB::getInstance();
- $p = $db->query("SELECT * FROM permissions WHERE id = ?",array($id))->first();
- echo $p->name;
- }
- // Generate Random String
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
Advertisement
Add Comment
Please, Sign In to add comment