Exemple #1
0
/**
*	purpose:	calculate new SSI based on GAME results between vdate1 -> vdate2
* 				stores new SSI in stat-table
* 	params:		date,date
*	returns:	output as ECHO statements
*/
function generateStaticSSIStatisticEntries($vdate1, $vdate2)
{
    # //
    # // v01 BH 12.7.2003 initial version - works
    # // run game query -> store pid,points in array (PID=index)
    # // run loop on every player - add points from array ... or from last SSI
    # // v02 BH for every player get the gamecount for this period and set the STATUS flag
    # // v03 added Rule 1 and rule 2
    # // v04 re-worked for ls_statsadmin
    global $dbi, $user, $redpic, $greenpic, $minSSIVal, $goback;
    if (!isset($vdate1)) {
        die("Error: no START date" . $goback);
    }
    if (!isset($vdate2)) {
        die("Error: no END date" . $goback);
    }
    $srecords = sql_query("select pid,pfname,plname,rid,rgid,rpid,rresult,rdate,rdesc,statval" . " from tplayer,tresult,tblstat" . " where pid=rpid and pid=statpid and statcode=2 and statdate = '{$vdate1}' and rdate>'{$vdate1}' and rdate<'{$vdate2}'" . " order by rdate,rgid asc,rresult desc", $dbi);
    $i = 0;
    $lastgame = 0;
    $arr = array();
    while (list($pid, $pfname, $plname, $rid, $rgid, $rpid, $rresult, $rdate, $rdesc, $sippoints) = sql_fetch_row($srecords, $dbi)) {
        #
        # es gibt immer 2 entries pro Spiel -> darstellung in einer Reihe
        # SORTORDER = WINNER A / Loser B -> Sieger immer in Record 1 Loser in Record 2
        # momentan entpricht der valAwin immer dem -valBWin (also reziprok wert ...)
        # der dynamic faktor liegt fr alle spieler bei 50 =(200/4)=3:1
        #
        $i = $i + 1;
        if ($rgid != $lastgame) {
            $sipA = $sippoints;
            $pidA = $pid;
        } else {
            $sipB = $sippoints;
            $pidB = $pid;
            # // calculate PLAYER A WINNER //////////
            $valAwin = ReturnSSIChangePlayer($sipA, $sipB, 1);
            # // calculate PLAYER B Loser /////////
            $valBLost = ReturnSSIChangePlayer($sipB, $sipA, 0);
            #debug("A PID=$pidA Value Arr=$arr[$pidA] adding $valAwin");
            #debug("B PID=$pidB Value Arr=$arr[$pidB] adding ".(-$valBLost));
            $arr[$pidA] = $arr[$pidA] + $valAwin;
            $arr[$pidB] = $arr[$pidB] + -$valBLost;
            $gamecount[$pidA] = $gamecount[$pidA] + 1;
            $gamecount[$pidB] = $gamecount[$pidB] + 1;
        }
        $lastgame = $rgid;
    }
    echo "<h3>Abrechnung der Spielresultate Periode {$vdate1} / {$vdate2}</h3><p>Zwecks &Uuml;berpr&uuml;fung oder einer manuellen Buchhaltung k&ouml;nnen die angezeigten Daten mit copy-paste &uuml;bernommen und z.B. anderweitig gesichert werden.<br>SSI Base Value={$minSSIVal}</p>";
    #foreach ($arr as $key => $valwin){
    #	echo "Valarray $key = $valwin<br>";
    #}
    # // now get the playerslist cycle with an INSERT into tblstat on $vdate2
    $pqry = sql_query("select pid,pfname,plname,statval from tplayer,tblstat where pid=statpid and statdate='{$vdate1}' and statcode=2 order by pid", $dbi);
    while (list($pid, $pfname, $plname, $sippoints) = sql_fetch_row($pqry, $dbi)) {
        if ($arr[$pid] != 0) {
            # // Rule 1 any player can not gain or loose more than 200 points
            if ($arr[$pid] > 200) {
                $arr[$pid] = 200;
            }
            if ($arr[$pid] < -200) {
                $arr[$pid] = -200;
            }
            # // get new value from $arr array and add to existing value from last period
            # // Rule 2 SSI can not get lower than 600 !!! //
            $newval = $sippoints + $arr[$pid];
            if ($newval < $minSSIVal) {
                $newval = $minSSIVal;
            }
            echo "{$greenpic}<b> NEW SSI for {$pfname} {$plname}: adding " . number_format($arr[$pid], 2, '.', '') . " pt to {$sippoints} for {$vdate1}/{$vdate2} = {$newval}</b></br>";
            #//echo "insert into tblstat values(0,'$vdate2',".($sippoints+$arr[$pid]).",$pid)<br>";
            $qry = "insert into tblstat(statid,statdate,statcode,statval,statpid) values(0,'{$vdate2}',2,{$newval},{$pid})";
            $res = sql_query($qry, $dbi);
            dsolog(2, $user, "<b>SSI UPDATE</b> {$pfname} {$plname} = {$newval}");
        } else {
            echo "{$redpic}<i>NO SSI update for {$pfname} {$plname} Points: " . number_format($arr[$pid], 2, '.', '') . "</i></br>";
            #//echo "insert into tblstat values(0,'$vdate2',".$sippoints.",$pid)<br>";
            $qry = "insert into tblstat(statid,statdate,statcode,statval,statpid) values(0,'{$vdate2}',2,{$sippoints},{$pid})";
            $res = sql_query($qry, $dbi);
            dsolog(1, $user, "<b>NO SSI UPDATE</b> {$pfname} {$plname} = {$sippoints}");
        }
        # // TOGGLE the SSI status field for this player case 0, -6, +6
        # // this is used to know how actual the current SSI value is
        switch ($gamecount[$pid]) {
            case 0:
                $res = sql_query("update tplayer set psipstatus=0 where pid={$pid}", $dbi);
                break;
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                $res = sql_query("update tplayer set psipstatus=1 where pid={$pid}", $dbi);
                break;
            default:
                $res = sql_query("update tplayer set psipstatus=2 where pid={$pid}", $dbi);
                break;
        }
        # // end switch status toggle
    }
}
Exemple #2
0
function dso_delplayer($vpid)
{
    global $dbi, $usertoken;
    if (!is_numeric($vpid)) {
        die('E1');
    }
    if ($usertoken['usertype_id'] < 5) {
        return '<font color=red>Err85:AccType</font>';
    }
    $res1 = sql_query('delete from tplayer where pid=' . $vpid . ' LIMIT 1', $dbi);
    dsolog(3, $usertoken['uname'], "DELETED Player Record ({$vpid})");
}
Exemple #3
0
function _LS_saveGame($match_key, $eventID, $aRes)
{
    /*
     * TODO v5 change to json string encoding G:L:P: as in the savelegs ...
     * in ax-POST mode we always have 2/4 arrays
     * currently: gpid:gid:pid:tid:legs
     * find out what is needed to win a set in this event ...
     */
    global $dbi, $usertoken;
    $event = reteventconfig($eventID);
    $legsforset = ceil($event['evsgllegs'] / 2);
    $out = 0;
    foreach ($aRes as $a) {
        $res = explode(':', $a);
        if (sizeof($res) > 2) {
            if ($res[4] >= $legsforset) {
                $sSET = ',gplegswon=' . $res[4] . ',gpsetwon=1';
            } else {
                $sSET = ',gplegswon=' . $res[4] . ',gpsetwon=0';
            }
            $qry = 'UPDATE tblgameplayer set gppid=' . $res[2] . $sSET . '  WHERE gpid=' . $res[0] . ' and gptid=' . $res[3] . ' limit 1';
            $p1 = sql_query($qry, $dbi);
            $out = $out + $p1;
        }
    }
    #debug('New Result '.$aRes[0].':'.$aRes[1].' Match '.$match_key.' by direct edit.');
    dsolog(1, $usertoken['uname'], 'Result ' . $aRes[0] . ':' . $aRes[1] . ' Match: ' . $match_key . '.');
    return $out;
}
Exemple #4
0
function _submitMatchResult($vmkey, $eventid, $vtid, $vsets, $vlegs)
{
    /*
     * unlike the saveMatch function this is triggered by non-priviledged users
     * here we have only calculated values - no check save as they are ...
     * TODO -> this is 60% identical to _saveMatch function ...
     * TODO -> check if this can be replaced by the axEditor ...
     * + saveresults status GreenRing ($$greencrosspic) and send message URL
     */
    global $event, $dbi, $LS_LEVEL, $usertoken;
    $editmode = 0;
    $editmode = retAccessThisMatchKey($vmkey);
    if ($LS_LEVEL < 2 && $editmode == 0) {
        die("<h3>No access ...{$editmode}</h3>");
    }
    # // save values into the match-team-assignment table
    $ret = DB_UpdateMatchTeamResults($vmkey, $eventid, $vtid, $vsets, $vlegs);
    if ($ret != 2) {
        die("<h3>Error saving Match result values...</h3>");
    }
    // JUST set STATUS to SUBMITTED
    $ret = DB_setMatchStatus($vmkey, 5);
    if ($ret != 1) {
        die('<h3>Event: (' . $event['evname'] . ') Match: ' . $vmkey . ' Status Update failed ...</h3>');
    }
    dsolog(1, $usertoken['uname'], 'Result ' . $vsets[0] . ':' . $vsets[1] . ' for Match $vmkey submitted for review');
    // MESSAGE BUS
    if ($usertoken['ttypeuser_id'] < 3) {
        $msg = $event['evname'] . ' Result ' . $vsets[0] . ':' . $vsets[1] . ' submitted by Account ' . $usertoken['uname'] . ' - please review using the system link below.';
        $url = 'ls_system.php?func=showmatch&vmkey=' . $vmkey . '&eventid=' . $eventid;
        $ret = DB_setMessage($usertoken['uname'], 1, 1, $msg, $url, $event['mgroup_id']);
        if ($ret != 1) {
            die('<h3>Event: (' . $event['evname'] . ') Match: ' . $vmkey . ' Request for approval could not be sent.</h3>');
        }
    }
    _sendpendingmails();
}
Exemple #5
0
function _deleteStatsEntries($vsyscode, $vdeldate)
{
    # delete selected static table entries for syscode and passed date
    global $dbi, $user, $SSI_LEVEL;
    if (!isset($vdeldate)) {
        die("No date selected");
    }
    if ($SSI_LEVEL < 3) {
        die("<h1>Not allowed ...</h1>");
    }
    $deleteqry = "DELETE FROM tblstat WHERE statdate='{$vdeldate}' and statcode={$vsyscode}";
    $res1 = sql_query($deleteqry, $dbi);
    if ($res1) {
        echo "(" . $res1 . ") " . $deleteqry;
    }
    dsolog(3, $user, "DELETED ALL STATS Records for ({$vdeldate})");
}
Exemple #6
0
function purgedsolog()
{
    global $user, $dbi;
    $resx = sql_query("delete from tdsolog where lid>1", $dbi);
    dsolog(3, $user, "LOG Table purged and cleaned.");
}
Exemple #7
0
/**
*	purpose:	handler for the incoming Leg Detail DATA
* 	params:		json string
*	returns:	0/1
*/
function _saveLegs($eventID, $match_key, $str_LData)
{
    /*
     * here we receive a mixture of update and insert requests
     */
    global $usertoken;
    $aLDATA = explode('|', $str_LData);
    if (sizeof($aLDATA) < 1) {
        debug('E131:LegDATA empty');
    }
    $p = 0;
    foreach ($aLDATA as $L) {
        if (strlen($L) > 3) {
            $aLegValues = explode(',', $L);
            if (sizeof($aLegValues) < 3) {
                debug('E:135:UnexpectedLegData');
            }
            $p += _LS_InsUpdateLegRecord($eventID, $aLegValues);
        }
    }
    dsolog(1, $usertoken['uname'], 'Saved Legs: Match ' . $match_key . ' Data:' . $str_LData);
    return $p;
}
Exemple #8
0
/**
 * actually handle the insert / Update logic based on the PASSNUMBER + type_id
 * param: aP=named array with PlayerData
 */
function _InsertUpdatePlayer($aP, $passkey = 'pfkey1')
{
    /* ------------------------
    * v03 BH 2006/11/20 for Player Import DATA
    * v031 after db version 3 - only a minimum is needed for the creation
    * TODO v5 merge this and the dso_player_code to the ORM Modell ...
    * TODO v5 replace model by using player_foreignkey table
    * -----------------------		
    */
    global $dbi, $usertoken;
    $update = 0;
    $pid = 0;
    $pidstore = 0;
    # set defaults
    $thisdate = ls_getdate();
    # A - check which PASSNUMBER to sync on the fieldname is stored in any $passkey
    $pidstore = dso_checkPlayerByPassNr($aP['passnr']);
    if ($pidstore > 0) {
        $MSG = "Player with Pass Number: " . $aP['passnr'] . " found in DB trying sync on PID={$pidstore}";
    } else {
        $MSG = "Pass with Number: " . $aP['passnr'] . " NOT found in DB checking name+birthdate.";
        # CHECK B  try to obtain PID via name+birthdate combination
        $pidstore = dso_checkPlayerByNameAndBirth($aP['firstname'], $aP['lastname'], $aP['birthdate']);
        if ($pidstore > 0) {
            $MSG = $MSG . ' Found Match, running sync on PID=' . $pidstore;
        }
    }
    # check the insert flag ..... and output ...
    # we NEVER update the passnr - this is the sync point !!
    $OUT = "Pass:"******" Name:" . $aP['firstname'] . " " . $aP['lastname'] . " Adr:" . $aP['town'] . " " . $aP['plz'] . " " . $aP['street'] . "</td></tr>";
    if ($pidstore > 0) {
        $qry = "update tplayer set pfname=\"" . $aP['firstname'] . "\",plname=\"" . $aP['lastname'] . "\",pbirthdate=\"" . $aP['birthdate'] . "\",ptel1=\"" . $aP['tel1'] . "\",ptel2=\"" . $aP['tel2'] . "\"," . "pemail=\"" . $aP['email'] . "\",pnationality=\"" . $aP['nation'] . "\",ptown=\"" . $aP['town'] . "\",pplz=\"" . $aP['plz'] . "\",pstreet=\"" . $aP['street'] . "\",pactive=1,pupd_user=\"" . $usertoken['uname'] . "\"," . "pupd_date=\"{$thisdate}\",pcomment=\"" . $aP['comment'] . "\" where pid={$pidstore} limit 1";
        $res = sql_query($qry, $dbi);
        if ($res == 1) {
            print "<tr><td>{$MSG}</td><td bgcolor='#eedd88'>UPDATE " . $OUT;
            dsolog(2, $usertoken['uname'], "<b>eGate UPDATE:</b> " . $OUT);
        } else {
            print "<tr><td>{$MSG}</td><td bgcolor='#ee4444'>FAILED " . $OUT;
            dsolog(2, $usertoken['uname'], "<b>eGate FAILURE UPDATE:</b> " . $OUT);
        }
    } else {
        /*
         * when exactly are we doing AUTO-INSERTS ???
         */
        $qry = "insert into tplayer(" . "pid,pfname,plname,pgender,pactive,pcomment,pbirthdate,pcre_date,pcre_user,ptel1,ptel2,pemail,pnationality,ptown,pplz,pstreet,{$passkey})" . " values(0,\"" . $aP['firstname'] . "\",\"" . $aP['lastname'] . "\",\"" . $aP['gender'] . "\",1,\"" . $aP['comment'] . "\",\"" . $aP['birthdate'] . "\",\"{$thisdate}\",\"" . $usertoken['uname'] . "\",\"" . $aP['tel1'] . "\",\"" . $aP['tel2'] . "\",\"" . $aP['email'] . "\",\"" . $aP['nation'] . "\",\"" . $aP['town'] . "\",\"" . $aP['plz'] . "\",\"" . $aP['street'] . "\",\"" . $aP['passnr'] . "\")";
        $res = sql_query($qry, $dbi);
        if ($res == 1) {
            print "<tr><td>{$MSG}</td><td bgcolor='#88ff88'>NEW " . $OUT;
            dsolog(2, $usertoken['uname'], "<b>eGate INSERT:</b> " . $OUT);
        } else {
            print "<tr><td>{$MSG}</td><td bgcolor='#FF8888'>NEW Player FAILED " . $OUT;
            dsolog(2, $usertoken['uname'], "<b>eGate FAILURE INSERT:</b> " . $OUT);
        }
    }
}
Exemple #9
0
function _insupdverein($vvid, $vrealm, $vlogic, $vname, $vfullname, $vaddressclub, $vort, $vbundesland, $vemail, $vwebsite, $vaddress, $vmembercount, $vsoft = 1, $vsteel = 1, $vhomepagelink = 0, $tpolmeldung = 'NULL', $oedsopagelink = 0)
{
    /*
     * insert or update record
     * parse values and check on sanity ....
     * 05.2008 switched to usertoken
     * Allowed users => registermap=2 + vereinsaccount=vvid
     */
    global $sipgoback, $dbi, $usertoken;
    // CHECK 1
    if ($usertoken['usertype_id'] < 2) {
        die('<h3>E:V1:Type:' . $usertoken['usertype_id'] . '</h3>' . $sipgoback);
    }
    // CHECK 2
    if ($usertoken['usertype_id'] == 2) {
        if (!$usertoken['verein_id'] == $vvid) {
            die('<h3>E:V2:WrongVerein:' . $usertoken['verein_id'] . '</h3>' . $sipgoback);
        }
    } else {
        if ($usertoken['registermap'][$vrealm] < 2) {
            die('<h3>E:V3:RegisterRightsMissing</h3>' . $sipgoback);
        }
    }
    // CHECK 3 Incoming variables ...
    if (strlen($vname) == 0) {
        die('E:V4:Vereinsname <b>muss</b> angegeben werden ... ' . $sipgoback);
    }
    if (!ereg("([1-9]{1})", $vrealm)) {
        die('E:V4:Zust&auml;ndigkeit <b>muss</b> angegeben werden ... ' . $sipgoback);
    }
    if (strlen($vlogic) > 2) {
        $vlogic = substr($vlogic, 0, 2);
    }
    if (!is_numeric($vmembercount)) {
        $vmembercount = 1;
    }
    if (!ereg("([0-1]{1})", $vsoft)) {
        $vsoft = 0;
    }
    if (!ereg("([0-1]{1})", $vsoft)) {
        $vsteel = 0;
    }
    if (!ereg("([0-1]{1})", $vhomepagelink)) {
        $vhomepagelink = 0;
    }
    if (!ereg("([0-1]{1})", $oedsopagelink)) {
        $oedsopagelink = 0;
    }
    // FINALLY ACTION Based on ID
    // cre_INFO and upd_info
    $d = getdate();
    $upd_date = $d['year'] . '-' . $d['mon'] . '-' . $d['mday'];
    // TODO replace by ORM code ...
    if ($vvid > 1) {
        $qry = "update tverein set verband_id={$vrealm}, vlogic=\"{$vlogic}\",vname=\"{$vname}\", vfullname=\"{$vfullname}\"," . "vaddressclub=\"{$vaddressclub}\", vort=\"{$vort}\", vbundesland=\"{$vbundesland}\", vemail=\"{$vemail}\"," . "vwebsite=\"{$vwebsite}\", vaddress=\"{$vaddress}\", vmembercount={$vmembercount}, vsoft={$vsoft}," . "vsteel={$vsteel} ,vhomepagelink={$vhomepagelink}, oedsopagelink={$oedsopagelink}, tpolmeldung=\"{$tpolmeldung}\"," . "cre_user='******'uname'] . "', cre_date=\"{$upd_date}\" where vid={$vvid}";
    } else {
        $qry = "INSERT into tverein (verband_id,vlogic,vname,vfullname,vaddressclub,vort,vbundesland,vemail,vwebsite,vaddress," . "vmembercount,vsoft,vsteel,vhomepagelink,oedsopagelink,tpolmeldung,cre_user,cre_date)" . " VALUES (" . $vrealm . ",'{$vlogic}','{$vname}','{$vfullname}','{$vaddressclub}','{$vort}','{$vbundesland}','{$vemail}', '{$vwebsite}', '{$vaddress}',{$vmembercount},{$vsoft},{$vsteel},{$vhomepagelink},{$oedsopagelink},'{$tpolmeldung}','" . $usertoken['uname'] . "','{$upd_date}')";
    }
    #debug($qry);
    $res = sql_query($qry, $dbi);
    dsolog(1, $usertoken['uname'], '<b>SAVE Verein:</b> ' . $vname . ' (' . $vaddress . ')');
}
Exemple #10
0
/**
*	purpose:	save the matchresult into tblmatchteam / tblmatch and set status to = 5
* 	params:		array SETS array LEGS
*	returns:	1 / 0
*/
function _saveMatch($match_key, $aSets, $aLegs, $match_status)
{
    global $dbi, $usertoken, $aMkey;
    // there is no insert .... this is update only ...
    // get eventconfig
    // only save when incoming USER is higher ranked than previous user, store usertype in field=usercode
    // save results to tblmatchteam
    // save match to tblmatch
    // debug($aMkey);
    $aPoints = array();
    $event = reteventconfig($aMkey['event']);
    $myUserCode = $usertoken['usertype_id'];
    if ($myUserCode == 2) {
        $match_status = 5;
    } else {
        // just to make sure a second check ...
        if ($usertoken['eventmap'][$event['id']] < 2) {
            die_red('E99:AccTokenMap');
        }
    }
    if ($aSets[0] > $aSets[1]) {
        $aPoints[0] = $event['evpointswin'];
        $aPoints[1] = 0;
    } elseif ($aSets[0] == $aSets[1]) {
        $aPoints[0] = $event['evpointseven'];
        $aPoints[1] = $event['evpointseven'];
    } elseif ($aSets[0] < $aSets[1]) {
        $aPoints[0] = 0;
        $aPoints[1] = $event['evpointswin'];
    }
    $qry1 = 'UPDATE tblmatchteam set usercode=' . $myUserCode . ', mtlegs=' . $aLegs[0] . ',mtlegslost=' . $aLegs[1] . ',mtsets=' . $aSets[0] . ',mtsetslost=' . $aSets[1] . ',mtpoints=' . $aPoints[0] . ' WHERE usercode<=' . $myUserCode . ' AND mtmkey=\'' . $match_key . '\' AND mttid=' . $aMkey['home'] . ' limit 1';
    $p1 = sql_query($qry1, $dbi);
    $qry2 = 'UPDATE tblmatchteam set usercode=' . $myUserCode . ',mtlegs=' . $aLegs[1] . ',mtlegslost=' . $aLegs[0] . ',mtsets=' . $aSets[1] . ',mtsetslost=' . $aSets[0] . ',mtpoints=' . $aPoints[1] . ' WHERE usercode<=' . $myUserCode . ' AND mtmkey=\'' . $match_key . '\' AND mttid=' . $aMkey['away'] . ' limit 1';
    $p2 = sql_query($qry2, $dbi);
    $qry3 = 'update tblmatch set usercode=' . $myUserCode . ',mstatus=' . $match_status . ' where usercode<=' . $myUserCode . ' AND mkey="' . $match_key . '"';
    $p3 = sql_query($qry3, $dbi);
    dsolog(1, $usertoken['uname'], 'Result ' . $aSets[0] . ':' . $aSets[1] . ' for Match ' . $match_key . ' saved');
    if ($p1 + $p2 + $p3 == 3) {
        return 1;
    } else {
        return 0;
    }
}
Exemple #11
0
function _insupdplayer($v_pid = 0, $last_name = '')
{
    # ------------------------
    # v02 BH 2003/7/3
    # v07 BH 10.9. included add fields
    # v09 BH removed vverband this is done auto by vrealm
    # // v10 removed membership entries - just basic player details ...
    # -----------------------
    # TODO v5 merge this and the egate_code to the ORM Modell ...
    if (isset($_POST['vfname']) && strlen(dounhtmlentities($_POST['vfname'])) < 30) {
        $first_name = strip_tags($_POST['vfname']);
    } else {
        $first_name = '';
    }
    if (isset($_POST['vbirthdate']) && strlen(dounhtmlentities($_POST['vbirthdate'])) < 15) {
        $v_birthdate = strip_tags($_POST['vbirthdate']);
    } else {
        $v_birthdate = '1901-01-01';
    }
    if (isset($_POST['vgender']) && strlen(dounhtmlentities($_POST['vgender'])) < 2) {
        $v_gender = strip_tags($_POST['vgender']);
    } else {
        $v_gender = 'H';
    }
    if (isset($_POST['vactive']) && is_numeric(dounhtmlentities($_POST['vactive']))) {
        $v_active = strip_tags($_POST['vactive']);
    } else {
        $v_active = 1;
    }
    if (isset($_POST['vcomment']) && strlen(dounhtmlentities($_POST['vcomment'])) < 50) {
        $v_comment = strip_tags($_POST['vcomment']);
    } else {
        $v_comment = '';
    }
    $v_username = '';
    if (isset($_POST['vnation']) && strlen(dounhtmlentities($_POST['vnation'])) < 12) {
        $v_nation = strip_tags($_POST['vnation']);
    } else {
        $v_nation = '';
    }
    if (isset($_POST['vtown']) && strlen(dounhtmlentities($_POST['vtown'])) < 30) {
        $v_town = strip_tags($_POST['vtown']);
    } else {
        $v_town = '';
    }
    if (isset($_POST['vplz']) && strlen(dounhtmlentities($_POST['vplz'])) < 10) {
        $v_plz = strip_tags($_POST['vplz']);
    } else {
        $v_plz = '';
    }
    if (isset($_POST['vstreet']) && strlen(dounhtmlentities($_POST['vstreet'])) < 60) {
        $v_street = strip_tags($_POST['vstreet']);
    } else {
        $v_street = '';
    }
    if (isset($_POST['vtel1']) && strlen(dounhtmlentities($_POST['vtel1'])) < 20) {
        $v_tel1 = strip_tags($_POST['vtel1']);
    } else {
        $v_tel1 = '';
    }
    if (isset($_POST['vtel2']) && strlen(dounhtmlentities($_POST['vtel2'])) < 20) {
        $v_tel2 = strip_tags($_POST['vtel2']);
    } else {
        $v_tel2 = '';
    }
    if (isset($_POST['vemail']) && strlen(dounhtmlentities($_POST['vemail'])) < 80) {
        $v_email = strip_tags($_POST['vemail']);
    } else {
        $v_email = '';
    }
    global $dbi, $sipgoback, $usertoken;
    dsolog(2, $usertoken['uname'], "<b>UPDATE REQUEST</b> Player: {$last_name}({$v_pid})");
    if ($usertoken['usertype_id'] < 2 && $usertoken['usertype_id'] != 0) {
        die("<h3>Illegal attempt to change data ....</h3>");
    }
    if (sizeof($usertoken['registermap']) < 1 && $usertoken['usertype_id'] != 0) {
        die("<h3>Illegal attempt to change data .......</h3>");
    }
    #
    # sanity checks come here please ........
    #
    $v_gender = strtoupper($v_gender);
    if (!ereg("([H,D,J]{1})", $v_gender)) {
        die("Wrong Gender should be H,D or J ... {$sipgoback}");
    }
    if (checkBirthDate($v_birthdate) == 0) {
        die("Geburtsdatum ist <b>kein g&uuml;ltges Datum</b> ... {$sipgoback}");
    }
    if (strlen($last_name) == 0) {
        die("Nachname <b>muss</b> angegeben werden ... {$sipgoback}");
    }
    if (strlen($first_name) == 0) {
        die("Vorname <b>muss</b> angegeben werden ... {$sipgoback}");
    }
    /*
     * in case of an insert the PID=0, check if unique
     */
    if ($v_pid == 0) {
        $playerlist = CheckUniquePlayer($first_name, $last_name, $v_birthdate);
        if (!strlen($playerlist) == 0) {
            die("<h3>Achtung, Doppel Eintr&auml;ge gefunden:</h3><p>Vorname, Nachname, Geburtsdatum ident:</p><br/>" . $playerlist . "<br/><br/> ...{$sipgoback}");
        }
    }
    $upd_user = $usertoken['uname'];
    $upd_date = ls_getdate();
    if (!ereg("([0-1]{1})", $v_active)) {
        die("<h3>Aktiv Flag entweder 0 oder 1</h3> ... {$sipgoback}");
    }
    // FINALLY ACTION
    if ($v_pid > 1) {
        $qry = "update tplayer set pfname=\"{$first_name}\",plname=\"{$last_name}\",pgender=\"{$v_gender}\"," . "pactive={$v_active},pcomment=\"{$v_comment}\",pusername=\"{$v_username}\",pbirthdate=\"{$v_birthdate}\"," . "pupd_user=\"{$upd_user}\",pupd_date=\"{$upd_date}\",pnationality=\"{$v_nation}\"," . "ptown=\"{$v_town}\",pplz=\"{$v_plz}\",pstreet=\"{$v_street}\",ptel1=\"{$v_tel1}\",ptel2=\"{$v_tel2}\",pemail=\"{$v_email}\" where pid={$v_pid} limit 1";
    } else {
        $qry = "insert into tplayer (pid,pfname,plname,pgender,pactive,sipcount,pcomment,pusername,psipstatus,pbirthdate,pcre_date,pcre_user,ptel1,ptel2,pnationality,ptown,pplz,pstreet,pemail)  values(0,\"{$first_name}\",\"{$last_name}\",\"{$v_gender}\",1,0,\"{$v_comment}\",\"{$v_username}\",0,\"{$v_birthdate}\",\"{$upd_date}\",\"{$upd_user}\",\"{$v_tel1}\",\"{$v_tel2}\",\"{$v_nation}\",\"{$v_town}\",\"{$v_plz}\",\"{$v_street}\",\"{$v_email}\")";
    }
    $res = sql_query($qry, $dbi);
    return $res;
}
Exemple #12
0
function _delTeam($vtid, $eventid)
{
    # delete team entry and team-event entry ...
    global $dbi, $TEAM_LEVEL, $usertoken;
    if ($TEAM_LEVEL < 3) {
        die('E:T23:NoAccess');
    }
    if (!$vtid > 0) {
        die('E:T23:MissingTeamID');
    }
    $strSQL = 'DELETE from tblteamplayer where lteamid=' . $vtid . ' AND leventid=' . $eventid . ' limit 16';
    $res1 = sql_query($strSQL, $dbi);
    if ($res1 == 1) {
        debug("<i>Spieler - Team ({$vtid}) LineUp gel&ouml;scht.</i>");
    } else {
        debug("Error :: {$strSQL}");
    }
    $strSQL = "DELETE from tblteam where id={$vtid} limit 1";
    $res1 = sql_query($strSQL, $dbi);
    if ($res1 == 1) {
        debug("<i>Team Eintrag {$vtid} gel&ouml;scht.</i>");
        dsolog(3, $usertoken['uname'], "DELETED Team Entry {$vtid} and Lineup");
    } else {
        debug("Error :: {$strSQL}");
    }
}