Ejemplo n.º 1
0
function checkAction($chkVal)
{
    $w = "chkVal='" . $chkVal . "'";
    if (isset($_SESSION['config']) && $_SESSION['config']->CURRENTUSER->USERID != null) {
        $w .= " and user_id=" . $_SESSION['config']->CURRENTUSER->USERID;
    }
    $dbTblTest = new DbTable($_SESSION['config']->DBCONNECT, "chkActions", array("*"), "", "", "id desc", $w);
    if ($dbTblTest->getRowCount() > 0) {
        $r = $dbTblTest->getRow(1);
        if ($r->getNamedAttribute("chkVal") == $chkVal) {
            return false;
        }
    }
    $r = $dbTblTest->createRow();
    $r->setNamedAttribute("user_id", $_SESSION['config']->CURRENTUSER->USERID);
    $r->setNamedAttribute("chkVal", $chkVal);
    $r->insertIntoDB();
    return true;
}
Ejemplo n.º 2
0
function addFriendRequest($userId, $friendId)
{
    $dbTblFriends = new DbTable($_SESSION['config']->DBCONNECT, "freundesliste", array("user_id", "friend_id", "accepted"), "", "accepted = 'N'", "", "user_id=" . $userId . " AND friend_id=" . $friendId);
    if ($dbTblFriends->getRowCount() > 0) {
        echo "Dieser Benutzer ist bereits in Ihrer Freundesliste, oder Sie haben bereits eine Anfrage gestellt.";
        return;
    }
    $dbRowNewFriend = $dbTblFriends->createRow();
    $dbRowNewFriend->setNamedAttribute("user_id", $userId);
    $dbRowNewFriend->setNamedAttribute("friend_id", $friendId);
    $dbRowNewFriend->setNamedAttribute("accepted", "N");
    $dbRowNewFriend->insertIntoDB();
    echo "Freundesanfrage gesendet";
}
 function checkSwitch()
 {
     if (isset($_REQUEST['schalte']) && $_REQUEST['schalte'] != 0) {
         $dbActionLog = new DbTable($_SESSION['config']->DBCONNECT, "action_log", array("sessionid", "userid", "zeit"), "Session, Benutzer, Timestamp", "", "geaendert desc", "sessionid='?schalte=" . $_REQUEST['schalte'] . "'" . (strlen($_REQUEST['dimmer']) > 0 ? "-" . $_REQUEST['dimmer'] : "") . (strlen($_REQUEST['tmstmp']) > 0 ? " AND zeit=" . $_REQUEST['tmstmp'] : ""));
         if (count($dbActionLog->ROWS) == 0) {
             if (strlen($_REQUEST['tmstmp']) <= 0) {
                 $_REQUEST['tmstmp'] = time();
             }
             $actionLogRow = $dbActionLog->createRow();
             $actionLogRow->setNamedAttribute("sessionid", "?schalte=" . $_REQUEST['schalte']);
             $actionLogRow->setNamedAttribute("userid", $_SESSION['config']->CURRENTUSER->USERID);
             $actionLogRow->setNamedAttribute("zeit", $_REQUEST['tmstmp']);
             $actionLogRow->insertIntoDB();
             //echo "Dimmer: ".$_REQUEST['dimmer'];
             $dayInMillis = 86400000;
             $dbActionLog->setWhere("zeit is null or zeit < " . ($_REQUEST['tmstmp'] - $dayInMillis));
             $dbActionLog->refresh();
             foreach ($dbActionLog->ROWS as $r) {
                 $r->deleteFromDb();
             }
             $this->switchObject($_REQUEST['schalte'] > 0 ? $_REQUEST['schalte'] : -$_REQUEST['schalte'], $_REQUEST['schalte'] > 0 ? "on" : "off", $_REQUEST['dimmer']);
         }
     }
 }