* Set INSTANCE\_ID (this is how you call your instalation, hostname, organization, etc...)
* Set BARCODE\_TYPE (that will be used for printing barcodes)
* Set BARCODE\_PREFIX (this will be used for generating unique barcodes if you have more instalations)
- * Set $fake\_lms\_users (If you want to use login credentials different from your DB user/password)
+ * Set $internal\_auth\_users (If you want to use login credentials different from your DB user/password)
* @author Tomas Mudrunka
*/
class Sklad_HTML extends HTML { //TODO: Split into few more methods
- function header($title='', $uid=0, $user='') {
+ function header($title='', $user=array()) {
$home = URL_HOME;
$script = $_SERVER['SCRIPT_NAME'];
$search = htmlspecialchars(@trim($_GET['q']));
$message = strip_tags(@trim($_GET['message']),'<a><b><u><i>');
$instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
+ $user_id = htmlspecialchars($user['id']);
+ $user_gid = htmlspecialchars($user['gid']);
+ $user_name = htmlspecialchars($user['name']);
//$title = T($title); //TODO
$html = $this->head("SōkoMan$title");
$html .= <<<EOF
<h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
-<div style="float:right">Loged in as $user [UID $uid]</div>
+<div style="float:right">Loged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]</div>
<style type="text/css">
* { font-family: arial; }
$row_quoted[$column] = '0';
break;
case $table.'_author':
- $row_quoted[$column] = $this->auth->get_authorized_user_id();
- //die($this->auth->get_authorized_user_id().'=USER');
+ $row_quoted[$column] = $this->auth->get_user_id();
+ //die($this->auth->get_user_id().'=USER');
break;
}
}
//Sephirot:
if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcode') //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost...
- echo $this->html->header($PATH_INFO,$this->db->auth->get_authorized_user_id());
+ echo $this->html->header($PATH_INFO,$this->db->auth->get_user());
switch($PATH_CHUNKS[1]) { //TODO: Move some branches to plugins if possible
case 'test': //test
die('Tell me why you cry');
* @author Tomas Mudrunka
*/
class Sklad_Auth_common {
- function get_authorized_user_id($die=true) {
- if(isset($this->authorized_user_id)) return $this->authorized_user_id;
+ function get_user($die=true) {
+ if(isset($this->user)) return $this->user;
if($die) die('No user authorized!!!');
return false;
}
+
+ function get_user_id($die=true) {
+ $user = $this->get_user($die);
+ return $user['id'];
+ }
}
require_once(BACKEND_AUTH.'.php');
*/
class Sklad_Auth extends Sklad_Auth_common { //FAKE!
function check_auth($user, $pass) {
- $users = array( //You can specify multiple users in this array
- DB_USER => DB_PASS
+ $users = array(
+ DB_USER => array(DB_PASS,0,0)
);
- if(isset($GLOBALS['fake_lms_users'])) $users = $GLOBALS['fake_lms_users'] + $users;
- $this->authorized_user_id=23; //Auth user_id
- return (isset($users[$user]) && ($users[$user] == $pass));
+ if(isset($GLOBALS['internal_auth_users'])) $users = $GLOBALS['internal_auth_users'] + $users;
+ if(isset($users[$user][0]) && ($users[$user][0] == $pass)) {
+ $this->user['name']=$user;
+ $this->user['id']=$users[$user][1];
+ $this->user['gid']=$users[$user][2];
+ return true;
+ }
+ return false;
}
}
define('URL_IMAGES', URL_HOME.'/images');
define('URL_BARCODES', URL_HOME.'/barcodes');
+define('BACKEND_AUTH', 'internal');
+define('BACKEND_ACCOUNTING', 'internal');
+
define('LOCALE_LANG', 'en');
define('INSTANCE_ID', '');
define('BARCODE_TYPE', 'code128b');
define('BARCODE_PREFIX', 'STORE/');
-$fake_lms_users = array( //You can specify multiple users in this array
- DB_USER => DB_PASS
+$internal_auth_users = array( //You can specify multiple users in this array
+ //'username' => array('password', 'uid','gid'),
+ DB_USER => array(DB_PASS, 0,0)
);