- function query($sql) {
- $this->rc=@$this->db->query($sql);
- if ($this->debug) $this->showDebug($sql);
- if(DB::isError($this->rc)) {
- $this->dbFehler($sql,$this->rc->getMessage());
- return false;
- } else {
- return $this->rc;
- }
- }
- function getAll($sql) {
- $this->rc=@$this->db->getAll($sql,DB_FETCHMODE_ASSOC);
- if ($this->debug) $this->showDebug($sql);
- if(DB::isError($this->rc)) {
- $this->dbFehler($sql,$this->rc->getMessage());
- return false;
- } else {
- return $this->rc;
- }
- }
+function anmelden() {
+ ini_set("gc_maxlifetime","3600");
+ $tmp = @file_get_contents("../config/authentication.pl");
+ preg_match("/'db'[ ]*=> '(.+)'/",$tmp,$hits);
+ $dbname=$hits[1];
+ preg_match("/'password'[ ]*=> '(.+)'/",$tmp,$hits);
+ $dbpasswd=$hits[1];
+ preg_match("/'user'[ ]*=> '(.+)'/",$tmp,$hits);
+ $dbuser=$hits[1];
+ preg_match("/'host'[ ]*=> '(.+)'/",$tmp,$hits);
+ $dbhost=($hits[1])?$hits[1]:"localhost";
+ preg_match("/'port'[ ]*=> '?(.+)'?/",$tmp,$hits);
+ $dbport=($hits[1])?$hits[1]:"5432";
+ preg_match("/[ ]*\\\$self->\{cookie_name\}[ ]*=[ ]*'(.+)'/",$tmp,$hits);
+ $cookiename=$hits[1];
+ if (!$cookiename) $cookiename='lx_office_erp_session_id';
+ $cookie=$_COOKIE[$cookiename];
+ if (!$cookie) header("location: ups.html");
+ $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie);
+ if (!$auth) { return false; };
+ $_SESSION["sessid"]=$cookie;
+ $_SESSION["cookie"]=$cookiename;
+ $_SESSION["employee"]=$auth["login"];
+ $_SESSION["mansel"]=$auth["dbname"];
+ $_SESSION["dbname"]=$auth["dbname"];
+ $_SESSION["dbhost"]=(!$auth["dbhost"])?"localhost":$auth["dbhost"];
+ $_SESSION["dbport"]=(!$auth["dbport"])?"5432":$auth["dbport"];
+ $_SESSION["dbuser"]=$auth["dbuser"];
+ $_SESSION["dbpasswd"]=$auth["dbpasswd"];
+ $_SESSION["db"]=new myDB($_SESSION["dbhost"],$_SESSION["dbuser"],$_SESSION["dbpasswd"],$_SESSION["dbname"],$_SESSION["dbport"],$showErr);
+ $_SESSION["authcookie"]=$authcookie;
+ $sql="select * from employee where login='".$auth["login"]."'";
+ $rs=$_SESSION["db"]->getAll($sql);
+ if(!$rs) {
+ return false;
+ } else {
+ if ($rs) {
+ $tmp=$rs[0];
+ $_SESSION["termbegin"]=(($tmp["termbegin"]>=0)?$tmp["termbegin"]:8);
+ $_SESSION["termend"]=($tmp["termend"])?$tmp["termend"]:19;
+ $_SESSION["Pre"]=$tmp["pre"];
+ $_SESSION["interv"]=($tmp["interv"]>0)?$tmp["interv"]:60;
+ $_SESSION["loginCRM"]=$tmp["id"];
+ $_SESSION["lang"]=$tmp["countrycode"]; //"de";
+ $_SESSION["kdview"]=$tmp["kdview"];
+ $sql="select * from defaults";
+ $rs=$_SESSION["db"]->getAll($sql);
+ $_SESSION["ERPver"]=$rs[0]["version"];
+ return true;
+ } else {
+ return false;
+ }
+ }
+}