<?php
// Start Session
session_start();
// Every public function is listed in one class
class jewelbeastUserSystem {
public $currentUser;
public $users_table;
public $username_field;
public $password_field;
protected $_query;
protected $_numRows;
protected $_fetchArray;
public function __construct() {
// Initialize MySQL Database
// Enter your database login details here (Host, Login, Password) followed by the Database name
mysql_connect('localhost', 'root', '');
mysql_select_db('jewelbeast');
// The table and fields used. This can be set up with an existing user database.
$this->users_table = 'users';
$this->username_field = 'username';
$this->password_field = 'password';
$this->banned = 'banned';
$this->activated = 'active';
$this->userLevel = 'userlevel';
$this->standardLevel = '728956';
// Initialize user if signed in
if(isset($_SESSION['user'])) {
$query = $this->query("SELECT * FROM `".$this->users_table."` WHERE `".$this->username_field."` = '".$_SESSION['user']."';");
if($this->_numRows == 1) {
$this->currentUser = $_SESSION['user'];
}
}
}
// Safer Query function. Mostly used for Update queries. Feel free to use this as your general Query.
public function safeQuery($query) {
mysql_real_escape_string($query);
$args = array_slice(func_get_args(),1);
$args = array_map(array($this, 'safeQuery'),$args);
return mysql_query(vsprintf($query,$args));
}
// General Query
public function query($sql) {
$this->_query = mysql_query($sql);
$this->_numRows = mysql_num_rows($this->_query);
$this->_fetchArray = mysql_fetch_assoc($this->_query);
}
// String sanitize
public function sanitize($string) {
$string = mysql_real_escape_string($string);
return $string;
}
// Safe redirect
public function redirect($url) {
header('location:'.$url);
exit;
}
// Get Database row
public function getRow($table, $row = "", $id = "1", $where = "") {
$this->query("SELECT * FROM `".$table."`...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.