Example #1
0
 public function __construct($param, $config, $db = "")
 {
     $server = "dcatvi05.tmw.ac.at";
     $param->set("current_time", iso(time()));
     // autentification
     $auth = new LDAP($server);
     //==========================================================
     switch ($param->cmd()) {
         /*****************************************
          * autentification: log in
          */
         case "login":
             # replace . to whitespace
             $user = str_replace(".", " ", $param->user());
             # if user and password -> try login
             if ($user and $param->password()) {
                 # log in
                 if ($auth->login($user, $param->password())) {
                     $_SESSION["logged"] = true;
                     $_SESSION["user"] = $auth->user();
                 } else {
                     $_SESSION["logged"] = false;
                     $_SESSION["user"] = false;
                 }
             }
             break;
             /*****************************************
              * autentification: log out
              */
         /*****************************************
          * autentification: log out
          */
         case "logout":
             unset($_SESSION["logged"]);
             unset($_SESSION["user"]);
             break;
             /*****************************************
              * database add data
              *   if query defined, add occurence of all field supported
              *   without query, add new record
              */
         /*****************************************
          * database add data
          *   if query defined, add occurence of all field supported
          *   without query, add new record
          */
         case "add":
             $add_data = [];
             //				debug($db);
             $add = new Config($config->add());
             $add_fields = $add->get($param->db_cmd());
             if ($add_fields) {
                 foreach ($add_fields["data"] as $key => $value) {
                     # timestamp
                     if ($value == "NOW") {
                         $add_data[$key] = iso(time());
                     }
                     # data for field
                     if ($param->get($value)) {
                         $add_data[$key] = $param->get($value);
                     }
                 }
             }
             # add occurence
             if (array_key_exists("query", $add_fields)) {
                 $query = replace_param($add_fields["query"], $param->get());
                 $db->add_occ($query, $add_data);
             } else {
                 $db->add($add_data);
             }
             /*****************************************
              * database delete records
              */
         /*****************************************
          * database delete records
          */
         case "delete":
             foreach ($param->get() as $key => $value) {
                 if (substr($key, 0, 6) == "delete") {
                     //						debug($value);
                     $db->remove($value);
                 }
             }
             break;
     }
 }