Beispiel #1
0
function cancel_order($orderid, $uid)
{
    // cancel an order
    $query = "\n        UPDATE orderbook\n        SET status='CANCEL'\n        WHERE\n            orderid='{$orderid}'\n            AND uid='{$uid}'\n            AND status='OPEN'\n    ";
    do_query($query);
    if (mysql_affected_rows() != 1) {
        if (mysql_affected_rows() > 1) {
            throw new Error('Serious...', 'More rows updated than should be. Contact the sysadmin ASAP.');
        } else {
            if (mysql_affected_rows() == 0) {
                throw new Problem(_('Cannot...'), _('Your order got bought up before you were able to cancel.'));
            } else {
                throw new Error('Serious...', 'Internal error. Contact sysadmin ASAP.');
            }
        }
    }
    // Refetch order in case something has happened.
    $info = fetch_order_info($orderid);
    if ($uid != $info->uid) {
        throw new Error('Permission...', '... Denied! Now GTFO.');
    }
    add_funds($info->uid, $info->amount, $info->type);
    // these records indicate returned funds.
    create_record($orderid, $info->amount, 0, 0, -1, 0);
    addlog(LOG_RESULT, "  cancelled order {$orderid}");
}
Beispiel #2
0
/**
 * Devuelve la traducción de la cadena recibida
 * según la lengua en uso; la signature de la
 * función es la misma de sprintf
 * (http://es.php.net/manual/en/function.sprintf.php)
 *
 * @return string
 */
function x()
{
    global $i18n;
    //sólo se carga en el hash $i18n el fichero de la lengua en uso
    $args = func_get_args();
    $key = array_shift($args);
    if (count($args) == 1 && is_array($args[0])) {
        $args = $args[0];
    }
    if (!isset($i18n)) {
        $tmp = $key;
    } elseif (empty($i18n[$key])) {
        $tmp = $key;
        addlog(__FILE__, $key);
    } else {
        $tmp = $i18n[$key];
    }
    if (!is_array($args)) {
        $args = array();
    }
    array_unshift($args, $tmp);
    $tmp = call_user_func_array('sprintf', $args);
    return $tmp;
}
Beispiel #3
0
function switcher($page)
{
    global $is_logged_in, $is_admin, $is_verified;
    try {
        $lock = false;
        if (!preg_match("/^[0-9_a-z]*\$/", $page)) {
            $page = 'junk';
        }
        // delay showing the header when logging in until we know whether the login worked or not
        if ($page != 'download' && $page != 'login' && $page != 'graph') {
            show_header($page, $is_logged_in);
        }
        if ($is_logged_in) {
            get_user_lock($lock = $is_logged_in);
        }
        addlog(LOG_SWITCHER, sprintf("[%s] visit page '%s'", getenv("REMOTE_ADDR"), $page));
        switch ($page) {
            ////////////////////////////////////////////////////////////////////////
            // for general consumption
            ////////////////////////////////////////////////////////////////////////
            case '404':
            case 'graph':
            case 'help':
            case 'news':
            case 'orderbook':
            case 'test':
            case 'trade':
            case 'view_trades':
                include "{$page}.php";
                break;
                ////////////////////////////////////////////////////////////////////////
                // for logged in users only
                ////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////
            // for logged in users only
            ////////////////////////////////////////////////////////////////////////
            case 'api':
            case 'deposit':
            case 'identity':
            case 'place_order':
            case 'profile':
            case 'statement':
            case 'turn_on_duo':
            case 'view_order':
            case 'view_request':
            case 'withdraw':
                if ($is_logged_in) {
                    include "{$page}.php";
                } else {
                    log_badpage($page);
                }
                break;
                ////////////////////////////////////////////////////////////////////////
                // for admin only
                ////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////
            // for admin only
            ////////////////////////////////////////////////////////////////////////
            case 'add_cash':
            case 'bank':
            case 'commission':
            case 'docs':
            case 'download':
            case 'freeze':
            case 'users':
                if ($is_admin) {
                    include "{$page}.php";
                } else {
                    log_badpage($page);
                }
                break;
            case 'login':
                if (!$is_logged_in) {
                    include "login.php";
                    // we just tried to log in, so check whether or not it worked before showing the footer
                    get_login_status();
                } else {
                    addlog(LOG_LOGIN, "  already logged in");
                    log_badpage($page);
                }
                break;
            case 'logout':
                setcookie('autologin', FALSE, time() - 60 * 60 * 24 * 365);
                logout();
            default:
                sleep(3);
                log_badpage($page);
                break;
        }
        // debugging for session stuff
        if (0) {
            echo "<div class='content_box'>\n";
            echo "<h3>Debug</h3>\n";
            echo "<p>\n";
            echo "session id: ", session_id(), "<br/>\n";
            echo "session age: ", time() - $_SESSION['creation_time'], " seconds<br/>\n";
            if (isset($inactivity)) {
                echo "you were inactive for {$inactivity} seconds<br/>\n";
            }
            echo "MAX_IDLE_MINUTES_BEFORE_LOGOUT = ", MAX_IDLE_MINUTES_BEFORE_LOGOUT, " minutes = ", MAX_IDLE_MINUTES_BEFORE_LOGOUT * 60, " seconds<br/>\n";
            echo "MAX_SESSION_ID_LIFETIME = ", MAX_SESSION_ID_LIFETIME, " minutes = ", MAX_SESSION_ID_LIFETIME * 60, " seconds<br/>\n";
            echo "</p></div>\n";
        }
    } catch (Error $e) {
        global $shown_header;
        report_exception($e, SEVERITY::ERROR);
        // Same as below, but flag + log this for review,
        if (!$shown_header) {
            show_header($page, $is_logged_in);
        }
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    } catch (Problem $e) {
        global $shown_header;
        if (!$shown_header) {
            show_header($page, $is_logged_in);
        }
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    } catch (Exception $e) {
        global $shown_header;
        if (!$shown_header) {
            show_header($page, $is_logged_in);
        }
        echo "<div class='content_box'><h3>Technical difficulties</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
    show_footer($is_logged_in, $is_admin, $is_verified);
    if ($lock) {
        release_lock($lock);
    }
}
Beispiel #4
0
<?php

	error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);  // [josip] za error reports

	header("Content-type: text/html; charset=utf-8");
	opendb();

	$Allow = getPriv("employees", session("user_id"));
	if ($Allow == False) echo header ('Location: ../permission/?l=' . $cLang);

	$ua=getBrowser();
	$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
	$yourbrowser1 = (bool) strpos($ua['userAgent'], "Macintosh");

	addlog(47);
?>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<?php
	if($yourbrowser == "1")
	{ ?>
	<style type="text/css">
		html { 
		    overflow: auto; 
		    -webkit-overflow-scrolling: touch; 

		}
		body {
Beispiel #5
0
    case 'none':
        myadminform($naso);
        break;
    case 'update':
        switch ($dconf[maindbtype]) {
            case 'mysql':
                if ($debug) {
                    dbg("MY new details", $myadminpost);
                }
                sql_azurirajAdmin($myc, $myadminpost);
                db_writedatachange($myc, 'admins');
                break;
        }
        reloadUrl('Continue', 'myadmin.php');
        print "<h1>Updated my admin: " . $myadminpost[username] . "</h1>\n";
        addlog(true, "Updated my admin: " . $myadminpost[username]);
        break;
}
//
// disconnect from main database
//
switch ($dconf[maindbtype]) {
    case 'mysql':
        sql_odspojise($myc);
        break;
}
?>

</body>
</html>
Beispiel #6
0
//Nun noch datei abspeichern
foreach ($image2 as $name => $array) {
    if ($array["newdesc"]) {
        addlog("Speichere neue Bildbeschreibung von {$name}.");
        if ($array["number"] == 1) {
            $cmtz = "Bot: notice of a derivative work added";
        } else {
            $cmtz = "Bot: notice of " . $array["number"] . " derivative works added";
        }
        wikiedit("commons.wikimedia.org", $name, $array["newdesc"], $cmtz, "true", $username, $password);
        sleep(15);
    }
    $image2[$name]["donetime"] = time() - 15;
}
addlog("Update Datenbank");
foreach ($image2 as $name => $array) {
    if ($array["derivatives"]) {
        foreach ($array["derivatives"] as $derivativfile) {
            $resu1 = mysql_query("UPDATE `u_luxo`.`derivativefx` SET `status`='done', `donetime`='" . mysql_real_escape_string($array["donetime"]) . "' WHERE CONVERT(`derivativefx`.`status` USING utf8) = 'open' AND CONVERT(`derivativefx`.`file` USING utf8) ='" . mysql_real_escape_string($name) . "' AND CONVERT(`derivativefx`.`derivative` USING utf8)='" . mysql_real_escape_string($derivativfile) . "'", $dblink) or die(mysql_error());
            echo "UPDATE `u_luxo`.`derivativefx` SET `status`='done', `donetime`='" . mysql_real_escape_string($array["donetime"]) . "' WHERE CONVERT(`derivativefx`.`status` USING utf8) = 'open' AND CONVERT(`derivativefx`.`file` USING utf8) ='" . mysql_real_escape_string($name) . "' AND CONVERT(`derivativefx`.`derivative` USING utf8)='" . mysql_real_escape_string($derivativfile) . "'\n";
        }
    }
    if ($array["error"]) {
        foreach ($array["error"] as $derivativfile) {
            $resu1 = mysql_query("UPDATE `u_luxo`.`derivativefx` SET `status`='noexist', `donetime`='" . mysql_real_escape_string($array["donetime"]) . "' WHERE CONVERT(`derivativefx`.`status` USING utf8) = 'open' AND CONVERT(`derivativefx`.`file` USING utf8) ='" . mysql_real_escape_string($name) . "' AND CONVERT(`derivativefx`.`derivative` USING utf8)='" . mysql_real_escape_string($derivativfile) . "'", $dblink) or die(mysql_error());
            echo "UPDATE `u_luxo`.`derivativefx` SET `status`='noexist', `donetime`='" . mysql_real_escape_string($array["donetime"]) . "' WHERE CONVERT(`derivativefx`.`status` USING utf8) = 'open' AND CONVERT(`derivativefx`.`file` USING utf8) ='" . mysql_real_escape_string($name) . "' AND CONVERT(`derivativefx`.`derivative` USING utf8)='" . mysql_real_escape_string($derivativfile) . "'\n";
        }
    }
}
addlog("Botdurchgang erfolgreich, Ende.");
<?php

require_once '../util.php';
$is_logged_in = 'sync_to_bitcoin';
foreach (bitcoin_list_accounts(CONFIRMATIONS_FOR_DEPOSIT) as $account => $balance) {
    if ($balance) {
        try {
            get_openid_for_user($account);
            // check they have an account
        } catch (Exception $e) {
            continue;
        }
        get_user_lock($account);
        addlog(LOG_CRONJOB, sprintf("add %s BTC for user %s", internal_to_numstr($balance), $account));
        sync_to_bitcoin((string) $account);
        release_lock($account);
    }
}
Beispiel #8
0
            print "<h1>Category with ID " . $catpost['id'] . " exists</h1>\n";
            reloadUrl('Continue', 'transcat.php');
            print "<script language=\"javascript\">\n";
            print "  url = 'showtranscat.php?name=" . $found[name] . "';\n";
            print "  openDialog( url , 'showtranscat' , 'width=300,height=300,resizable=yes,scrollbars=yes,status=yes' );\n";
            print "</script>\n";
            break;
        }
        switch ($dconf['dbtype']) {
            case 'mysql':
                sql_addCategory($myc, $catpost);
                break;
        }
        print "<h1>Category " . $catpost['id'] . " added</h1>\n";
        reloadUrl('Continue', 'transcat.php');
        addlog(true, "Category " . $catpost['id'] . " added");
        break;
    case 'update':
        sql_updateTransCat($myc, $catpost);
        print "<h1>Category type " . $catpost['type'] . " and original " . $catpost['original'] . " updated</h1>\n";
        reloadUrl('Continue', 'listtranscat.php');
        break;
    case 'delete':
        sql_deleteTransCat($myc, $catpost);
        print "<h1>Category type " . $catpost['type'] . " and original " . $catpost['original'] . " deleted</h1>\n";
        reloadUrl('Continue', 'listtranscat.php');
        break;
}
//
// disconnect from main database
//
Beispiel #9
0
            case 'mysql':
                sql_brisiAdmin($myc, $adminpost);
                db_writedatachange($myc, 'admins');
                break;
        }
        // notify deleted admin by email
        $adminpost['masteradmin'] = $dadmin['fullname'];
        $adminpost['nodename'] = $dconf['nodename'];
        $mbody = formattemplate($dconf['nonametvhome'] . "/templates/messages/admin.delete.english.txt", $adminpost);
        if ($debug) {
            dbg("email body", $mbody);
        }
        sendemail($adminpost['email'], "Your are no longer an NonameTV admin", $mbody);
        reloadUrl('Continue', 'index.php');
        print "<h1>Deleted admin: " . $adminpost['username'] . "</h1>\n";
        addlog(true, "Deleted admin: " . $adminpost['username']);
        break;
}
//
// disconnect from main database
//
switch ($dconf['dbtype']) {
    case 'mysql':
        sql_dodisconnect($myc);
        break;
}
?>

</body>
</html>
function rigorMortis()
{
    global $sVars, $rmd, $rmtick, $rmLastPush, $rmCount, $rmSCount, $rmSendCount, $rmBuffer, $rmStartTick, $rmLastID;
    global $rm, $rmMap;
    global $rmeHistory;
    global $send, $sendTo;
    $rmd = $rmtick;
    $rmtick = floor(microtime(true) * 1000) - $rmStartTick;
    $rmd = $rmtick - $rmd;
    $rmLastPush += $rmd;
    $rmSCount += $rmd;
    $rmCount++;
    //echo "RMD|$rmd|LAST|$rmLastPush\n";
    //echo "\033[s\033[0F\033[1;37;41m"; // Save cursor position, start color change
    //echo "Tick: " . $rmtick . " / Last: ".$rmLastPush; // Output server time
    //echo "\033[m\033[u"; // End color change, restore cursor position
    if ($rmLastPush >= 1000 / $rm['netFrequency']) {
        if (isset($sVars['observing'])) {
            /* Server Logic, Send & Receive Prefixes ################################################### SERVER LOGIC, SEND & RECEIVE PREFIXES #########################################################################
            			   
                        ----------======== SERVER LOGIC RULES =========-------------
                        All values ROUNDed to the thousandth. 3-point precision. (3.142)
                        
                        +-------------------------     SEND PREFIXES     ------------------------+
                        |                      THESE ARE  ALL PREFIXED WITH ~                    |
                        
                        vL[variable]T[value] - Set player variable [VARNAMELENGTH / NAME / VALUETYPECHAR / VALUE
                                                e.g. v5speed2300 <-- [300 being UI16]
                        ValueTypeChars. 1-4: BigEndian Integer, a-z: String of length [letter] (j=10)           //// Not yet implemented
                        
                        i## - Unsigned16 - Iterations since last push
                        xTICK - Unsigned32 - Ticks since server start [Caps out at about 39 months]
                        T"""""""" - String8 - HH:MM:SS Server Time
                        p## - Unsigned16 - Time since last net push
                        P# - Unsigned8 - Current packet being sent through this (in 1 second time frame)
                        
                        D## - Unsigned16 - CLIENT DISCONNECT [CLIENTID UI16]
            			
            			                    ALL DELTA UI16s ARE CURRENTLY TIME UI32s. RECEIVED VALUES ARE MULTIPLES OF 7BIT, SENT ARE OF 8BIT
            			
                        ========== Initiate...
                        Id##TTTT - Send player their client ID & servers current tick [UI16 / UI32 SERVER TIME-TICK]
                        IpXXXXYYYY - Initiate player [XPOS*10000 UI32 / YPOS*10000 UI 32]
                        IeXXYYWWHH - Initiate emitter [XPOS UI16 / YPOS UI 16 / WIDTH UI 16 / HEIGHT UI 16] // Not yet implemented
                        Iz##TIMEXXYYTHP - Initiate zombie [ZOMBIEID UI16 / TIME UI32 / XPOS UI16 / YPOS UI16 / TYPE UI8 / HP UI16]
            			Io##TIMEXXYYTT - Initiate object [OBJECTID UI16 / TIME UI32 / XPOS UI16 / YPOS UI16 / TYPE UI16 ]
                        
                        ========== Object...
                        Od##TIME - Object destroy [OBJECTID UI16 / TIME UI32]
                        Ou## - Object update variable [OBJECTID UI16 / TIME UI32 / VARIABLE UI8 / VALUE UI32]
                        
                        ========== World updates
                        Wp##XXXXYYYYDD - Push any players ID,X,Y to another player [ID / X / Y / REPLAYDELAY-aka-LERP UI 16]
                        Wl##DD - Push players lerp/ReplayDelay to another player [CLIENTID UI16 / REPLAYDELAY UI16]
            	    
            			W=##DD - Push players syncDelay to another player [TIME UI32 / SYNCDELAY UI32] // REMOVED
            	    
                        ========== Buffer updates
                        Bp##DDXXXXYYYYDDDDSS - PUSH: Player movement buffer addition - [CLIENTID UI16 / TIME UI32 / XPOS*1000 UI32 / YPOS*1000 UI16 / (DIR+PI)*1000 UI16 / SPEED UI16]
                        Bf##DD - PUSH: Player has fired [CLIENTID UI16 / TIME UI32]
                        BF##DDd - PUSH: Player changed facing direction to d [CLIENTID UI16 / TIME UI32 / DIRECTION UI8]
                        B=##DD - PUSH: Player is keeping alive  [CLIENTID UI16 / TIME UI32] ****POTENTIAL BANDWIDTH REDUCTION. NEVER/RARELY SEND THIS, BUT, INCREASE SIZE OF SENT DELTA****
                        
                        BZp##TIMEXXXXYYYYDDDDSS - PUSH: Zombie movement buffer add - [ZOMBIEID UI16 / TIME UI32 / XPOS*1000 UI32 / YPOS*1000 UI16 / (DIR+PI)*1000 UI16 / SPEED UI16]
                        BZc##TIMEID - PUSH: Zombie start chasing player ID at TIME [PID UI16 / TIME UI32 / ZOMBIEID16]
                        BZh##TIMEHP - PUSH: Zombie health [ZID UI16 / TIME UI32 / HP UI16]
                        
            			= - Ping player, wait for response to determine players latency.
            	    
                        +---------------------     RECEIVE PREFIXES     -------------------------+
                        |                   THESE ARE ALSO ALL PREFIXED WITH ~                   |
                        (Do not accept authoritative data. Inputs only). Add to buffer
                        
                        0x00DD - Stop all movement (for when user is holding a key, then changes focus) - Time UI28
                        -DD - Ping - Time UI28 // Client requests to keep connection open
            			= - Pong
                        kDD# - Keydown UI7 - Time UI28  ***ALL DELTA UI14'S ARE CURRENTLY UI28's***
                        KDD# - Keyup UI7 - Time UI28
                        fDD - Fire - Time UI28
                        FDD# - Facing direction - [TIME UI28 / DIRECTION UI7] // Not yet implemented
            			
                        R#GAMEDD - Request entry to GAME# UI7 / GAMESTART UI28 / REPLAYDELAY UI14
                        
                        +------------------------     OBJECT IDs      ----------------------------+
            			|                                                                         |
            			| 14bit: 0-16383, 16bit: 0-65535                                          |
            			|                                                                         |
            			| 1001 - Money :: [0] - Amount UI21 (0-2,097,152)
            			
            			*/
            $rmSendCount++;
            for ($i = 0; $i < count($sVars['observing']); $i++) {
                send("~i" . pack("n", $rmCount) . "p" . pack("n", $rmLastPush) . "x" . pack("N", $rmtick) . "P" . pack("C", $rmSendCount), $sVars['observing'][$i], true);
            }
            if (!$rmSendCount) {
                echo "\n";
            }
            //echo "OBS[$rmSendCount]";
        }
        //############################### ALL INITIATE ACTIONS NEED TO BE DONE BEFORE BUFFERS. IF NOT, BUFFER WILL HAVE NOTHING TO MODIFY
        //############################### INITIATE ACTIONS TIME SHOULD NOT BE REQUIRED BECAUSE BUFFER SHOULD COME ASAP AFTER
        // However, initiate actions should really only be sent on game request. Client should handle buffer-only updates after that
        if ($rm['gameRunning'][0]) {
            // Actions based on player buffers, players
            foreach ($rm['p'] as $j => &$k) {
                if (isset($k['game']) && isset($rmBuffer[$j])) {
                    /*if (count($rmBuffer[$j]) == 1) {
                    			$tmp = round(atan2($k['keyv'][1],$k['keyv'][0]),3);
                    			$calcArray = array($k[0],$k[1],$tmp,$k[3]); // Send oldx, oldy, oldDIR, oldSpeed
                    			$calcArray['size'] = $k['size']; // Must transmit size of this unit to run collision checks properly
                    			$tpos = calculateNewPosition($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1], $calcArray); // Send new delta along with unit values
                    			
                    			$k[0] = $tpos[0]; $k[1] = $tpos[1]; $k[2] = $tpos[2]; $k[3] = $tpos[3];
                    			
                    			$rmBuffer[$j][count($rmBuffer[$j])-1][1] = $rmtick;
                    		}*/
                    if (count($rmBuffer[$j]) == 1) {
                        // Pre-position collision checking
                        $tmp = round(atan2($k['keyv'][1], $k['keyv'][0]), 3);
                        //addlog("\033[1;37;44mPre-Colliz Chk: (".$k[0].",".$k[1].") From X: ".round(cos($tmp) * $k[3] * ($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1]-$k['lerp'])*0.001,3)." -or- ".$rmtick." - ".$rmBuffer[$j][count($rmBuffer[$j])-1][1]." - L".$k['lerp']);
                        $calcArray = array($k[0] + round(cos($tmp) * $k[3] * ($rmtick - $rmBuffer[$j][count($rmBuffer[$j]) - 1][1] - $k['lerp']) * 0.001, 3), $k[1] + round(sin($tmp) * $k[3] * ($rmtick - $rmBuffer[$j][count($rmBuffer[$j]) - 1][1] - $k['lerp']) * 0.001, 3), 'size' => $k['size']);
                        //addlog("Collision checking (".$calcArray[0].",".$calcArray[1].")");
                        $col = collisionCheck($calcArray);
                        // Check current position of this player and reposition them if necessary
                        if (isset($col['collision'])) {
                            if (count($rmBuffer[$j]) == 1) {
                                $k[0] = $col[0];
                                $k[1] = $col[1];
                                $send .= 'Bp' . pack('n', $j) . pack('N', $rmtick - $k['lerp']) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tmp + M_PI) * 1000)) . pack('n', $k[3]);
                                $rmBuffer[$j][count($rmBuffer[$j]) - 1][1] = $rmtick - $k['lerp'];
                                //addlog("LAST RMBUFFER CHANGED TO ".$rmtick-$k['lerp']);
                            } else {
                                // This triggers when releasing a key while pressed against a wall
                                //addlog("MORE THAN 1 BUFFER, WAS CHANGED TO ".$rmtick-$k['lerp']);
                                $k[0] = $col[0];
                                $k[1] = $col[1];
                                $send .= 'Bp' . pack('n', $j) . pack('N', $rmtick - $k['lerp']) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tmp + M_PI) * 1000)) . pack('n', $k[3]);
                                $rmBuffer[$j][count($rmBuffer[$j]) - 1][1] = $rmtick - $k['lerp'];
                            }
                        } else {
                            //$k[0] = $col[0]; $k[1] = $col[1];
                            //$rmBuffer[$j][count($rmBuffer[$j])-1][1] = $rmtick-$k['lerp'];
                        }
                        //addlog("\033[m");
                        // addlog("\033[1;33;40m".print_r($rmBuffer[$j],true)."\033[m");
                    }
                    //addlog("####XPOS:".$k[0].",YPOS:".$k[1]);
                    for ($i = 1; $i < count($rmBuffer[$j]); $i++) {
                        $tbuff = array();
                        $tmp = round(atan2($k['keyv'][1], $k['keyv'][0]), 3);
                        /*$calcArray = array($k[0],$k[1],$tmp,$k[3]); // Send oldx, oldy, oldDIR, oldSpeed
                        		$calcArray['size'] = $k['size']; // Must transmit size of this unit to run collision checks properly
                        		$tpos = calculateNewPosition($rmBuffer[$j][$i][1]-$rmBuffer[$j][$i-1][1], $calcArray); // Send new delta along with unit values
                        		
                        		$k[0] = $tpos[0]; $k[1] = $tpos[1]; $k[2] = $tpos[2]; $k[3] = $tpos[3];*/
                        // Standard position processing
                        // If old delta is newer than the current. Something was injected in the future incorrectly. Throwout next position update by merging deltas.
                        // This can stall for time but eventually will cause a problem. Too low latency, things walk through walls.
                        //if ($rmBuffer[$j][$i-1][1]>$rmBuffer[$j][$i][1]) { $rmBuffer[$j][$i-1][1] = $rmBuffer[$j][$i][1]; }
                        // Instead of the above; don't change the time of this buffer, just ignore it. Or it will cause issues with next iteration collision checks
                        //if ($rmBuffer[$j][$i-1][1]>$rmBuffer[$j][$i][1]) { $tmpd = 0; }
                        //else { $tmpd = $rmBuffer[$j][$i][1]-$rmBuffer[$j][$i-1][1]; }
                        $tmpd = $rmBuffer[$j][$i][1] - $rmBuffer[$j][$i - 1][1];
                        // Allow delta setting regardless
                        // Update 8/22/2013: All goes well until the buffer is larger than 1 and there is a collision. The next time the buffer is 1 again
                        // the delta gets so high it causes the unit to jump through the wall.
                        // Update: Seems this is partially caused by a drastically changing lerp while in-game.
                        // Update: Caused by clients latency changing, causing their time sync to be off of the servers. Even if lerp remains unchanged, a large change in latency will ruin collision checking.
                        //addlog("\033[1;37;41mPre-B2+Col Chk: (".$k[0].",".$k[1].") From X: ".round(cos($tmp) * $k[3] * ($tmpd)*0.001,3));
                        $k[0] += round(cos($tmp) * $k[3] * $tmpd * 0.001, 3);
                        // Set xpos from oldx + oldDIR * oldSP * newdelta
                        $k[1] += round(sin($tmp) * $k[3] * $tmpd * 0.001, 3);
                        // Set ypos from ypos + (oldDIR * oldSP * (newdelta))
                        $calcArray = array($k[0], $k[1], 'size' => $k['size']);
                        //addlog("B2+ Collision checking (".$calcArray[0].",".$calcArray[1].")");
                        //addlog("Buffer deltas ".$rmBuffer[$j][$i][1]." - ".$rmBuffer[$j][$i-1][1]."\033[m");
                        $col = collisionCheck($calcArray);
                        if (isset($col['collision'])) {
                            $k[0] = $col[0];
                            $k[1] = $col[1];
                            $send .= 'Bp' . pack('n', $j) . pack('N', $rmtick - $k['lerp']) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tmp + M_PI) * 1000)) . pack('n', $k[3]);
                            //$rmBuffer[$j][$i][1] = $rmtick-$k['lerp'];
                            //$rmBuffer[$j][$i][1] = $rmtick;
                        } else {
                            // Fires when pressing a key while already pressed against a wall, or just regular buffer additions.
                            if ($i == count($rmBuffer[$j]) - 1) {
                                //$rmBuffer[$j][$i][1] = $rmtick-$k['lerp'];
                            }
                        }
                        //addlog(print_r($k,true));
                        if ($rmBuffer[$j][$i][0] == chr(0)) {
                            // Movement ALL-STOP
                            $k[3] = 0;
                            $k['keyv'] = array(0, 0);
                            $k['keyb'] = array();
                            //addlog('Movement all-stop (Client lost focus)');
                            $send .= 'Bp' . pack('n', $j) . pack('N', $rmBuffer[$j][$i][1]) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($k[2] + M_PI) * 1000)) . pack('n', $k[3]);
                        } elseif ($rmBuffer[$j][$i][0] == '=') {
                            // Ping, to stay synced with server
                            //$send .= 'B='.pack('n',$j).pack('n',$rmBuffer[$j][$i][1]); // Forward this ping so other players deltas are correct
                            //addlog('Forwarded keep-alive ping');
                        } elseif ($rmBuffer[$j][$i][0] == 'k') {
                            // Keydown
                            //$k[0] += round($k['keyv'][0] * $k[3] * $rmBuffer[$j][$i][2]*0.001,3); // Set xpos from oldx + oldDIR * oldSP * newdelta
                            //$k[1] += round($k['keyv'][1] * $k[3] * $rmBuffer[$j][$i][2]*0.001,3);
                            //addlog('DO new calc: '.$k['keyv'][0].'*'.$k[3].'*'.($rmBuffer[$j][$i][1]-$rmBuffer[$j][$i-1][1])*0.001);
                            if (!in_array($rmBuffer[$j][$i][2], $k['keyb'])) {
                                // Only continue if keys aren't already down
                                $tbuff[3] = $k['speed'];
                                if ($rmBuffer[$j][$i][2] == 68) {
                                    // Right
                                    $k['keyb'][] = 68;
                                    $k['keyv'][0] += 1;
                                } elseif ($rmBuffer[$j][$i][2] == 87) {
                                    // Up
                                    $k['keyb'][] = 87;
                                    $k['keyv'][1] -= 1;
                                } elseif ($rmBuffer[$j][$i][2] == 65) {
                                    // Left
                                    $k['keyb'][] = 65;
                                    $k['keyv'][0] -= 1;
                                } elseif ($rmBuffer[$j][$i][2] == 83) {
                                    // Down
                                    $k['keyb'][] = 83;
                                    $k['keyv'][1] += 1;
                                }
                                $tbuff[2] = round(atan2($k['keyv'][1], $k['keyv'][0]), 3);
                                // Standard movement without collisions check
                                $send .= 'Bp' . pack('n', $j) . pack('N', $rmBuffer[$j][$i][1]) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tbuff[2] + M_PI) * 1000)) . pack('n', $tbuff[3]);
                                //addlog("#CLIENT".$j."MOVE@".$rmBuffer[$j][$i][1]."|X:".$k[0].",Y:".$k[1].",D:".$tbuff[2].",S:".$tbuff[3]);
                                // For now, when a key is pressed down, we will also broadcast this clients lerp
                                //$send .= 'Wl'.pack('n',$j).pack('n',$rm['p'][$j]['lerp']);
                                //addlog("Transmitted a lerp of: ".$rm['p'][$j]['lerp']);
                                // #REVISE: For now, we will ping the client to judge their lerp. Later this should be done periodically
                                //if (!isset($rm['p'][$j]['ping'])) { // Only prepare if not already waiting to receive pong
                                //	$send .= '=';
                                //	$rm['p'][$j]['ping'] = $rmtick; // Prepare to receive pong
                                //}
                                //$send .= 'Wl'.pack('n',$j).pack('n',$rm['p'][$j]['lerp']);
                                $k[2] = $tbuff[2];
                                // Update direction
                                $k[3] = $tbuff[3];
                                // Update new speed
                            }
                        } elseif ($rmBuffer[$j][$i][0] == 'K') {
                            // Keyup
                            //$k[0] += round($k['keyv'][0] * $k[3] * $rmBuffer[$j][$i][2]*0.001,3); // Set xpos from oldx + oldvectorx * oldSP * newdelta
                            //$k[1] += round($k['keyv'][1] * $k[3] * $rmBuffer[$j][$i][2]*0.001,3); // Set ypos from oldy + oldvectory * oldSP * newdelta
                            //addlog('UP new calc: '.$k['keyv'][0].'*'.$k[3].'*'.($rmBuffer[$j][$i][1]-$rmBuffer[$j][$i-1][1])*0.001);
                            //addlog('KeyBefore: '.var_dump($k['keyb']));
                            if ($rmBuffer[$j][$i][2] == 68) {
                                // Right
                                if (array_search(68, $k['keyb']) !== false) {
                                    $k['keyv'][0] -= 1;
                                    array_splice($k['keyb'], array_search(68, $k['keyb']), 1);
                                }
                            } elseif ($rmBuffer[$j][$i][2] == 87) {
                                // Up
                                if (array_search(87, $k['keyb']) !== false) {
                                    $k['keyv'][1] += 1;
                                    array_splice($k['keyb'], array_search(87, $k['keyb']), 1);
                                }
                            } elseif ($rmBuffer[$j][$i][2] == 65) {
                                // Left
                                if (array_search(65, $k['keyb']) !== false) {
                                    $k['keyv'][0] += 1;
                                    array_splice($k['keyb'], array_search(65, $k['keyb']), 1);
                                }
                            } elseif ($rmBuffer[$j][$i][2] == 83) {
                                // Down
                                if (array_search(83, $k['keyb']) !== false) {
                                    $k['keyv'][1] -= 1;
                                    array_splice($k['keyb'], array_search(83, $k['keyb']), 1);
                                }
                            }
                            //addlog('KeyAfter: '.var_dump($k['keyb']));
                            if (empty($k['keyb']) || !$k['keyv'][0] && !$k['keyv'][1]) {
                                //addlog('Player STOP empty?'.empty($k['keyvb']).'---or?'.(!$k['keyv'][0] && !$k['keyv'][1]));
                                $tbuff[3] = 0;
                                // Player speed has stopped
                                $tbuff[2] = $k[2];
                                // Direction can stay the same
                            } else {
                                $tbuff[2] = round(atan2($k['keyv'][1], $k['keyv'][0]), 3);
                                // Direction has simply changed
                                $tbuff[3] = $k[3];
                                // Speed remains the same
                            }
                            $send .= 'Bp' . pack('n', $j) . pack('N', $rmBuffer[$j][$i][1]) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tbuff[2] + M_PI) * 1000)) . pack('n', $tbuff[3]);
                            //addlog("#CLIENT".$j."MOVE@".$rmBuffer[$j][$i][1]."|X:".$k[0].",Y:".$k[1].",D:".$tbuff[2].",S:".$tbuff[3]);
                            $k[2] = $tbuff[2];
                            // Update direction
                            $k[3] = $tbuff[3];
                            // Update new speed
                        } elseif ($rmBuffer[$j][$i][0] == 'f') {
                            // We need to calculate this actual k0,k1 position at this time
                            // We can't just use [] because it ends up ruining the structure of the array. Deletes weapons
                            for ($int = 0; $int < count($rm['bullets']); $int++) {
                                if (!isset($rm['bullets'][$int])) {
                                    break;
                                }
                            }
                            $rm['bullets'][$int] = array($k[0], $k[1], $k['aim'] / (128 / (M_PI * 2)) - M_PI, $rm['bullets']['pistol']['speed'], $j);
                            $send .= 'Bf' . pack("n", $j) . pack("N", $rmBuffer[$j][$i][1]);
                            // Send clientID, delta
                            //addlog("##ADDED## Fire from client ".$j." @ ".$rmBuffer[$j][$i][1]);
                        } elseif ($rmBuffer[$j][$i][0] == 'F') {
                            $k['aim'] = $rmBuffer[$j][$i][2];
                            // To get dir from this:: players[i]['aim']/(128/(Math.PI*2))-Math.PI = Direction
                            $send .= 'BF' . pack("n", $j) . pack("N", $rmBuffer[$j][$i][1]) . pack("C", $rmBuffer[$j][$i][2]);
                            //addlog("#CLIENT".$j." FACES ".$rmBuffer[$j][$i][2]." @ ".$rmBuffer[$j][$i][1]);
                        }
                        if (isset($col['collision'])) {
                            // Position overwrite and movement reset due to previous collision
                            $send .= 'Bp' . pack('n', $j) . pack('N', $rmtick - $k['lerp']) . pack('N', round($k[0] * 1000)) . pack('N', round($k[1] * 1000)) . pack('N', round(($tmp + M_PI) * 1000)) . pack('n', $k[3]);
                        }
                        //$send .= 'Bp'.pack("n",$j).$rmBuffer[$j][0];
                    }
                    //addlog("@@@@XPOS:".$k[0].",YPOS:".$k[1]);
                    //////////// Post position collision checking
                    /*$tmp = round(atan2($k['keyv'][1],$k['keyv'][0]),3);
                    		$calcArray = array(
                    						   $k[0] + round(cos($tmp) * $k[3] * ($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1]-$k['lerp'])*0.001,3),
                    						   $k[1] + round(sin($tmp) * $k[3] * ($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1]-$k['lerp'])*0.001,3),
                    						   
                    						   //$k[0] + round(cos($tmp) * $k[3] * ($rmLastPush)*0.001,3),
                    						   //$k[1] + round(sin($tmp) * $k[3] * ($rmLastPush)*0.001,3),
                    						   
                    						   
                    						   'size' => $k['size']
                    						   );
                    		//addlog("Using ".$rmLastPush." not ".($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1]));
                    		addlog("Collision checking (".$calcArray[0].",".$calcArray[1].")");
                    		$col = collisionCheck($calcArray); // Check current position of this player and reposition them if necessary
                    		
                    		if (isset($col['collision'])) {
                    			$k[0] = $col[0]; $k[1] = $col[1];
                    			
                    			//$send = ''; // Cancel out any previous pending movement sends
                    			$send .= 'Bp'.pack('n',$j).pack('N',$rmtick-$k['lerp']).pack('N',round($k[0]*1000)).pack('N',round($k[1]*1000)).pack('N',round(($tmp+M_PI)*1000)).pack('n',$k[3]);
                    			$rmBuffer[$j][count($rmBuffer[$j])-1][1] = $rmtick-$k['lerp'];
                    		} else {
                    			//$k[0] = $col[0]; $k[1] = $col[1];
                    		}*/
                    // Calc new position
                    // Will periodically check for collisions and move players even if buffer has not changed
                    /*$tmp = round(atan2($k['keyv'][1],$k['keyv'][0]),3);
                    		$calcArray = array($k[0],$k[1],$tmp,$k[3]);
                    		$calcArray['size'] = $k['size'];
                    		
                    		$tpos = calculateNewPosition($rmtick-$rmBuffer[$j][count($rmBuffer[$j])-1][1], $calcArray);
                    		addlog("Calculated New Pos: (".$tpos[0].",".$tpos[1].")");
                    		$rmBuffer[$j][count($rmBuffer[$j])-1][1] = $rmtick; // Set the last time this buffer was accessed to current time. Makes ready for when a change to buffer comes, or next collision check.
                    		
                    		$k[0] = $tpos[0]; $k[1] = $tpos[1]; $k[2] = $tpos[2]; $k[3] = $tpos[3];*/
                    //$send .= 'Bp'.pack('n',$j).pack('N',$rmBuffer[$j][$i][1]).pack('N',round($k[0]*1000)).pack('N',round($k[1]*1000)).pack('N',round(($k[2]+M_PI)*1000)).pack('n',$k[3]);
                    $rmBuffer[$j] = array_slice($rmBuffer[$j], count($rmBuffer[$j]) - 1);
                    // Save the last sent packet to use for the next buffer push
                    //$rmBuffer[$j][0][1] = $rmtick; // Set the time last accessed of this buffer to current time
                } else {
                    //addlog("Client $j is not a player.");
                }
            }
            // Actions based on time
            for ($i = 0; $i < count($rm['emitters']); $i++) {
                if ($rmtick > $rm['emitters'][$i]['next']) {
                    $tmp = array(randomInt($rm['emitters'][$i][0], $rm['emitters'][$i][2]), randomInt($rm['emitters'][$i][1], $rm['emitters'][$i][3]), randomInt($rm['enemies'][$rm['emitters'][$i]['type']]['hp']));
                    $rm['emitters'][$i]['next'] = $rmtick + randomInt($rm['emitters'][$i]['frequency']);
                    $num = count($rm['enemies']) - (count($rm['enemies']['types']) + 1);
                    // Don't take into account string indices on enemies when counting
                    for ($j = 0; $j <= $num; $j++) {
                        if (!isset($rm['enemies'][$j])) {
                            $k = $j;
                            break;
                            // Find the earliest zombie ID slot we can use
                        }
                    }
                    //$j = count($rm['enemies'])-(count($rm['enemies']['types'])+1);
                    $rm['enemies'][$k] = array(0 => $tmp[0], 1 => $tmp[1], 2 => 0, 3 => 0, 'type' => $rm['emitters'][$i]['type'], 'hp' => $tmp[2], 'maxhp' => $tmp[2], 'attack' => array(0, 0));
                    $rmeHistory[$k] = array(array($rmtick, $tmp[0], $tmp[1], 0, 0));
                    addlog('Sent zombie [' . $k . ']:');
                    $tmpType = max(array_search($rm['emitters'][$i]['type'], $rm['enemies']['types']), 0);
                    // Try to find this emitter type to spawn or default to 0
                    $send .= 'Iz' . pack('n', $k) . pack('N', $rmtick) . pack('n', $tmp[0]) . pack('n', $tmp[1]) . pack('C', $tmpType) . pack('n', $tmp[2]);
                    // Initiate zombie
                }
            }
            // Enemy tick
            foreach ($rm['enemies'] as $j => &$k) {
                if (is_numeric($j)) {
                    if (isset($k['chasing'])) {
                        // #REVISE: $rmeHistory must be constantly optimized to reduce memory usage
                        $k[2] = round(atan2($rm['p'][$k['chasing']][1] - $k[1], $rm['p'][$k['chasing']][0] - $k[0]), 3);
                        // Set direction
                        if (distanceBetween($k[0], $k[1], $rm['p'][$k['chasing']][0], $rm['p'][$k['chasing']][1]) > $rm['enemies'][$k['type']]['stopDistance']) {
                            $k[3] = $rm['enemies'][$k['type']]['speed'];
                            $k[0] += round(cos($k[2]) * $k[3] * $rmLastPush * 0.001, 3);
                            $k[1] += round(sin($k[2]) * $k[3] * $rmLastPush * 0.001, 3);
                            //$update = true;
                            $rmeHistory[$j][] = array($rmtick, $k[0], $k[1], $k[2], $k[3]);
                        } else {
                            //if ($k[3] != 0) $update = true;
                            if ($k[3] != 0) {
                                addlog("FoolZombie {$j} stopped moving at " . $k[0] . "," . $k[1] . ".");
                                $k[3] = 0;
                                $rmeHistory[$j][] = array($rmtick, $k[0], $k[1], $k[2], $k[3]);
                            }
                            // Else, it's already 0, and stopped
                            // Stop moving if we are closer than the stopDistance
                        }
                    } else {
                        foreach ($rm['p'] as $l => &$m) {
                            // #REVISE: We should only check players that are physically nearby to enemy
                            if (isset($m['game'])) {
                                // Only set to chase if logged in to a game
                                if (distanceBetween($k[0], $k[1], $m[0], $m[1]) < $rm['enemies'][$k['type']]['chaseRange']) {
                                    // Initiate chase
                                    //addlog("Well $j is now chasing $l");
                                    $k['chasing'] = $l;
                                    //Let client know this enemy is chasing them
                                    $send .= 'BZc' . pack('n', $l) . pack('N', $rmtick) . pack('n', $j);
                                    //addlog('Send:::'.$send);
                                    //break; // This break is really f*****g things up. Game will lose complete sync. Later found in another foreach iteration, it might be a problem with using $l and $m as variables, as they are used again later for network send
                                    //addlog('Distance:'.distanceBetween($k[0],$k[1],$m[0],$m[1]).' <? '.$rm['enemies'][$k['type']]['chaseRange']);
                                } else {
                                    //addlog('No Distance:'.round(distanceBetween($k[0],$k[1],$m[0],$m[1]),3).' <? '.$rm['enemies'][$k['type']]['chaseRange']);
                                }
                            }
                        }
                    }
                }
            }
            //Bullet operations
            foreach ($rm['bullets'] as $j => &$k) {
                if (is_numeric($j)) {
                    // Only iterate over actual bullets
                    //echo var_dump($k);
                    //echo "Iterate".$j;
                    $k['last'] = array($k[0], $k[1]);
                    $k[0] = round($k[0] + cos($k[2]) * $k[3] * $rmLastPush * 0.001, 3);
                    $k[1] = round($k[1] + sin($k[2]) * $k[3] * $rmLastPush * 0.001, 3);
                    if ($k[0] < 0 || $k[1] < 0 || $k[0] > $rm['clientWidth'] || $k[1] > $rm['clientHeight']) {
                        // Client bounds only for now
                        //echo 'Removed bullet'.$j.'/::'.var_dump($rm['bullets'][$j]);
                        unset($rm['bullets'][$j]);
                    } else {
                        // If the bullet is still around, lets check all collisions
                        //echo ">BULLET:X:".$k[0].":Y:".$k[1]."<";
                        $collisions = array();
                        foreach ($rm['enemies'] as $n => &$o) {
                            if (is_numeric($n)) {
                                $rewind = array();
                                // This will be an array of the enemy where it was $usersDelay msecs ago
                                //$usersDelay = 0; // We'll need to know the users delay from user[bulletOwner][delay]
                                $usersDelay = $rm['p'][$k[4]]['lerp'];
                                for ($i = count($rmeHistory[$n]) - 1; $i >= 0; $i--) {
                                    // Start from the latest and movie back
                                    if ($rmeHistory[$n][$i][0] <= $rmtick - $usersDelay) {
                                        // Continue back through the array until we are at time of this user, and the currently iterated enemy
                                        $rewind = array(0, 0, $rmeHistory[$n][$i][3], $rmeHistory[$n][$i][4]);
                                        // Same direction and speed
                                        $tmpdel = $rmtick - $usersDelay - $rmeHistory[$n][$i][0];
                                        // Delta since this history point in time
                                        $rewind[0] = $rmeHistory[$n][$i][1] + cos($rmeHistory[$n][$i][3]) * $rmeHistory[$n][$i][4] * $tmpdel * 0.001;
                                        $rewind[1] = $rmeHistory[$n][$i][2] + sin($rmeHistory[$n][$i][3]) * $rmeHistory[$n][$i][4] * $tmpdel * 0.001;
                                        //////////echo '  |TICK'.$i.':'.$rmeHistory[$i][0].','.$rmeHistory[$i][1].','.$rmeHistory[$i][2].'|  ';
                                        //echo "\n\nPOSITION FOR $n AT TIME ".$rmtick."::".var_dump($rmeHistory[$n][$i])."\n\n";
                                        break;
                                    }
                                }
                                //These will throw undefined index errors if user makes an action at a time less than 0. (e.g. his delay is 3000 and $rmtick is only at 1000)
                                $collide = false;
                                @($rewind[0] -= $rm['enemies'][$o['type']][0] / 2);
                                // This will now contain the position of the enemy at currentTime MINUS
                                @($rewind[1] -= $rm['enemies'][$o['type']][1] / 2);
                                // userDelay. Allowing for proper bullet hit detection
                                @($rewind[2] = $rm['enemies'][$o['type']][0]);
                                @($rewind[3] = $rm['enemies'][$o['type']][1]);
                                //if (isset($rewind[0])) echo "\nBOUNDS($n)::".$rewind[0].",".$rewind[1].",".$rewind[2].",".$rewind[3];
                                if (isset($k['last'])) {
                                    $collide = colLineRect(array($k[0], $k[1], $k['last'][0], $k['last'][1]), $rewind);
                                } else {
                                    $collide = posInBounds(array($k[0], $k[1]), $rewind);
                                }
                                /* if (isset($k['last'])) {
                                				$collide = colLineRect(array($k[0],$k[1],$k['last'][0],$k['last'][1]),array($o[0]-$rm['enemies'][$o['type']][0]/2,$o[1]-$rm['enemies'][$o['type']][1]/2,$rm['enemies'][$o['type']][0],$rm['enemies'][$o['type']][1]));
                                			} else {
                                				$collide = posInBounds(array($k[0],$k[1]),array($o[0]-$rm['enemies'][$o['type']][0]/2,$o[1]-$rm['enemies'][$o['type']][1]/2,$rm['enemies'][$o['type']][0],$rm['enemies'][$o['type']][1]));
                                			} */
                                if ($collide) {
                                    //$collisions[] = $n;
                                    $collisions[] = array($n, distanceBetween($rm['p'][$k[4]][0], $rm['p'][$k[4]][1], $k[0], $k[1]));
                                    //break;
                                }
                            }
                        }
                        // Collision processing
                        $penetrating = false;
                        // Penetration will trigger damage on the same enemies more than once
                        if (!!count($collisions)) {
                            // If 1 or more collisions
                            if ($penetrating) {
                                for ($i = 0; $i < count($collisions); $i++) {
                                    $rm['enemies'][$collisions[$i][0]]['hp'] -= randomInt($rm['bullets']['pistol']['damage']);
                                    $rm['enemies'][$collisions[$i][0]]['hp'] = max(0, $rm['enemies'][$collisions[$i][0]]['hp']);
                                    // Don't allow lower than 0
                                    //$send .= 'BZh'.pack('n',$collisions[$i][0]).pack('N',$rmtick-$usersDelay).pack('n',$rm['enemies'][$collisions[$i][0]]['hp']); // Send zombie health update [ID / TIME / HP]
                                    foreach ($rm['p'] as $p => &$q) {
                                        if (isset($q['game'])) {
                                            if (!isset($sendTo[$p])) {
                                                $sendTo[$p] = '';
                                            }
                                            $sendTo[$p] .= 'BZh' . pack('n', $collisions[$i][0]) . pack('N', $rmtick - $usersDelay - $q['lerp']) . pack('n', $rm['enemies'][$collisions[$i][0]]['hp']);
                                            // Send zombie health update [ID / TIME / HP]
                                        }
                                    }
                                    addlog("Bullet {$j} Collided with ID:" . $collisions[$i][0] . " (" . $i . "," . count($collisions) . ") making new hp " . $rm['enemies'][$collisions[$i][0]]['hp']);
                                    if ($rm['enemies'][$collisions[$i][0]]['hp'] <= 0) {
                                        $send .= createObject($rm['enemies'][$collisions[$i][0]][0], $rm['enemies'][$collisions[$i][0]][1], 1001, $rmtick - $usersDelay);
                                        $val = randomInt(1, 20);
                                        $rm['objects'][$rmLastID]['value'] = $val;
                                        //$send .= 'Io'.pack('n',$k).pack('N',$rmtick-$usersDelay).pack('n',$rm['enemies'][$collisions[$i][0]][0]).pack('n',$rm['enemies'][$collisions[$i][0]][1]).pack('n',1001));
                                        addlog("New money: " . print_r($rm['objects'][$rmLastID], true));
                                        unset($rm['enemies'][$collisions[$i][0]]);
                                        // Destroy zombie
                                        addlog("Zombie " . $collisions[$i][0] . " destroyed");
                                    }
                                }
                            } else {
                                $closest = array(0, $collisions[0][1]);
                                for ($i = 1; $i < count($collisions); $i++) {
                                    if ($collisions[$i][1] < $closest) {
                                        $closest = array($i, $collisions[$i][1]);
                                    }
                                }
                                $closest = $collisions[$closest[0]][0];
                                $rm['enemies'][$closest]['hp'] -= randomInt($rm['bullets']['pistol']['damage']);
                                $rm['enemies'][$closest]['hp'] = max(0, $rm['enemies'][$closest]['hp']);
                                // Don't allow lower than 0
                                //$send .= 'BZh'.pack('n',$collisions[$i]).pack('N',$rmtick-$usersDelay).pack('n',$rm['enemies'][$collisions[$i]]['hp']); // Send zombie health update [ID / TIME / HP]
                                foreach ($rm['p'] as $p => &$q) {
                                    if (isset($q['game'])) {
                                        if (!isset($sendTo[$p])) {
                                            $sendTo[$p] = '';
                                        }
                                        $sendTo[$p] .= 'BZh' . pack('n', $closest) . pack('N', $rmtick - $usersDelay - $q['lerp']) . pack('n', $rm['enemies'][$closest]['hp']);
                                        // Send zombie health update [ID / TIME / HP]
                                    }
                                }
                                addlog("Bullet {$j} Collided with single target (" . $closest . ") making new hp " . $rm['enemies'][$closest]['hp']);
                                if ($rm['enemies'][$closest]['hp'] <= 0) {
                                    $send .= createObject($rm['enemies'][$closest][0], $rm['enemies'][$closest][1], 1001, $rmtick - $usersDelay);
                                    $val = randomInt(1, 20);
                                    $rm['objects'][$rmLastID]['value'] = $val;
                                    //$send .= 'Io'.pack('n',$k).pack('N',$rmtick-$usersDelay).pack('n',$rm['enemies'][$collisions[$i][0]][0]).pack('n',$rm['enemies'][$collisions[$i][0]][1]).pack('n',1001));
                                    addlog("New money: " . print_r($rm['objects'][$rmLastID], true));
                                    unset($rm['enemies'][$closest]);
                                    addlog("Zombie " . $closest . " destroyed");
                                }
                                unset($rm['bullets'][$j]);
                                // Remove bullet, unless this is a penetrating round
                            }
                        }
                    }
                }
            }
            /*_*/
            /*
            foreach ($rm['enemies'] as $j => &$k) {
            	if (is_numeric($j)) { // Only operate on 'ACTUAL' enemies
            		if (isset($k['chasing'])) {
            			$update = false;
            			$k[2] = round(atan2($rm['p'][$k['chasing']][1]-$k[1],$rm['p'][$k['chasing']][0]-$k[0]),3); // Set direction
            			if (distanceBetween($k[0],$k[1],$rm['p'][$k['chasing']][0],$rm['p'][$k['chasing']][1]) > $rm['enemies'][$k['type']]['stopDistance']) {
            				$k[3] = $rm['enemies'][$k['type']]['speed'];
            				$k[0] += cos($k[2]) * $k[3] * $rmLastPush*0.001;
            				$k[1] += sin($k[2]) * $k[3] * $rmLastPush*0.001;
            				//$update = true;
            			} else {
            				//if ($k[3] != 0) $update = true;
            				$k[3] = 0; // Stop moving if we are closer than the stopDistance
            			}
            			// ID, time, x, y, dir, speed
            			echo '>'.$j.'Chasing ';
            			if ($update) {
            				//addlog('Send: '.$k[0].','.$k[1].','.$k[2].','.$k[3]);
            				$send .= 'BZp' . pack('n',$j) . pack('N',$rmtick) . pack('N',round($k[0]*1000)) . pack('N',round($k[1]*1000)) . pack('N',round(($k[2]+M_PI)*1000)) . pack('n',$k[3]);
            			}
            		} else {
            			//addlog('K chasing not set');
            			foreach ($rm['p'] as $l => &$m) {
            				if (isset($m['game'])) { // Only set to chase if logged in
            					if (distanceBetween($k[0],$k[1],$m[0],$m[1]) < $rm['enemies'][$k['type']]['chaseRange']) { // Initiate chase
            						$k['chasing'] = $l; break;
            						addlog('Distance:'.distanceBetween($k[0],$k[1],$m[0],$m[1]).' <? '.$rm['enemies'][$k['type']]['chaseRange']);
            					} else {
            						addlog('No Distance:'.round(distanceBetween($k[0],$k[1],$m[0],$m[1]),3).' <? '.$rm['enemies'][$k['type']]['chaseRange']);
            					}
            				}
            			}
            		}
            	}
            }
            */
            if (!empty($send) || count($sendTo) > 0) {
                // Send everything processed
                foreach ($rm['p'] as $l => $m) {
                    if (isset($m['game'])) {
                        //addlog('SEND  TO ('.$l.') >~'.$send);
                        $tmpsend = '~' . $send;
                        if (isset($sendTo[$l])) {
                            $tmpsend .= $sendTo[$l];
                        }
                        send($tmpsend, $l, true);
                    }
                }
                $sendTo = array();
                // Buffer to store everything we're going to send to each player individually
                $send = '';
                // String to store things we'll send to everyone
            }
        }
        // End conditional check for- game is running
        //addlog('FULLTEMP:'.$tmp);
        //send("s$rmSendCount", $sVars['observing']);
        //send("sSend count: $rmSendCount");
        //send("~P".pack("C",$rmSendCount), $sVars['observing'], true);
        $rmLastPush = 0;
        // Reset time since push
        $rmCount = 0;
        // Reset iterations per push
    }
    // End check for is this time to push
    if ($rmSCount >= 1000) {
        foreach ($rm['p'] as $l => &$m) {
            if (isset($m['game'])) {
                if (!isset($m['ping'])) {
                    // Check and update latency
                    $send .= '=';
                    $m['ping'] = $rmtick;
                    // Prepare to receive pong
                }
                $send .= 'Wl' . pack('n', $l) . pack('n', $m['lerp']);
                // Send clients lerp out based on latency on next net push
                // Reset client variables that cause issues for server collision checking
                if ($GLOBALS['cVars'][$l]['name'] == 'reset') {
                    $rmBuffer[$l] = array();
                    $rmBuffer[$l][0] = array('=', 0);
                    //if (!isset($sendTo[$l])) $sendTo[$l] = '';
                    //$sendTo[$l] .= 'Id'.pack('n',$l).pack('N',$rmtick); // Re-initialize the current game time on the net for this client
                    addlog("HARD RESET PLAYER BUFFER");
                }
            }
        }
        $rmSendCount = 0;
        // Reset sends per second
        $rmSCount = 0;
        // Second timer
    }
}
Beispiel #11
0
$currDateTime2 = $currDateTime0->format($dateformat);
$currDateTime2 = addToDateU($currDateTime, -1, 'days', $dateformat);
//dd-MM-yyyy HH:mm
//now()->format("Y-m-d H:i:s");
$AllowedMaps = "11111";
$cntz = dlookup("select count(*) from pointsofinterest where active='1' and type=2 and clientid=" . Session("client_id"));
//$CurrentTime = DlookUP("select Convert(nvarchar(20), DATEADD(HOUR,(select timeZone from clients where ID=" . Session("client_id") . ") - 1,GETDATE()), 120) DateTime");
$tzone = pg_fetch_result($dsAll, 0, "timezone");
$tzone = $tzone - 1;
//$AllowAddPoi = getPriv("AddPOI", Session("user_id"))
//$AllowViewPoi = getPriv("ViewPOI", Session("user_id"))
//$AllowAddZone = getPriv("AddZones", Session("user_id"))
//$AllowViewZone = getPriv("ViewZones", Session("user_id"))
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
addlog(37, '');
?>

<style>
	.ui-autocomplete {
		max-height: 100px;
		overflow-y: auto;
		/* prevent horizontal scrollbar */
		overflow-x: hidden;
		/* add padding to account for vertical scrollbar */
		padding-right: 20px;
		z-index: 4000;
	}
</style>
<style type="text/css">
	.ui-button { margin-left: -1px; }
Beispiel #12
0
<?php 
include "../include/db.php";
include "../include/functions.php";
include "../include/params.php";
include "../include/dictionary2.php";
?>


<?php 
header("Content-type: text/html; charset=utf-8");
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
$yourbrowser1 = (bool) strpos($ua['userAgent'], "Macintosh");
addlog(46);
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<style type="text/css">
	<?php 
if ($yourbrowser == "1") {
    ?>
		html { 
		    overflow: auto; 
		    -webkit-overflow-scrolling: touch; 
		}
		body {
		    height: 100%;
		    overflow: auto; 
		    -webkit-overflow-scrolling: touch;
		}
Beispiel #13
0
<?php 
opendb();
?>

	<?php 
header("Content-type: text/html; charset=utf-8");
opendb();
$Allow = getPriv("employees", session("user_id"));
if ($Allow == False) {
    echo header('Location: ../permission/?l=' . $cLang);
}
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
$yourbrowser1 = (bool) strpos($ua['userAgent'], "Macintosh");
addlog(45);
?>
	<html>
	<head>
	<script type="application/javascript">
		lang = '<?php 
echo $cLang;
?>
';
	</script>
	<link rel="stylesheet" type="text/css" href="../style.css">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<style type="text/css"> 
		.menuTable { display:none; width:200px; } 
	</style>
	<link rel="stylesheet" type="text/css" href="../style.css">
Beispiel #14
0
<?php 
include "../include/functions.php";
include "../include/db.php";
?>

<?php 
include "../include/params.php";
include "../include/dictionary2.php";
$id = getQUERY("id");
$descr = getQUERY("desc");
opendb();
$desc = dlookup("select registration || ' (' || code || ')<br>GSM number: ' || gsmnumber from vehicles where gsmnumber='" . $descr . "'");
//echo $desc;
addlog($id, $desc);
closedb();
Beispiel #15
0
    //$allPOI = dlookup("select count(*) from pinpoints where clientID=" . session("client_id"));
    //$allPOIs As String = "false"
    //If allPOI < 1000 Then allPOIs = "true"
	
    $DefMap = pg_fetch_result($dsAll, 0, "defaultmap");
    	
    $currDateTime = new Datetime();
    $currDateTime = $currDateTime->format("d-m-Y H:i");
	$currDateTime1 = new Datetime();
	$currDateTime1 = $currDateTime1->format("d-m-Y");
	//dd-MM-yyyy HH:mm 
    //now()->format("Y-m-d H:i:s");

    $AllowedMaps = "11111";
    
	addlog(32, '');

    $cntz = dlookup("select count(*) from pointsofinterest where type=2 and clientid=" . Session("client_id"));
    //$CurrentTime = DlookUP("select Convert(nvarchar(20), DATEADD(HOUR,(select timeZone from clients where ID=" . Session("client_id") . ") - 1,GETDATE()), 120) DateTime");
    $tzone = pg_fetch_result($dsAll, 0, "timezone");
	$tzone = $tzone - 1;
 
	$AllowAddPoi = getPriv("AddPOI", Session("user_id"));
	$AllowViewPoi = getPriv("ViewPOI", Session("user_id"));
	$AllowAddZone = getPriv("AddZones", Session("user_id"));
	$AllowViewZone = getPriv("ViewZones", Session("user_id"));

	$pauseTemp = array(5,10,15,20,25,30,35,40,45,50,55,60);
?>
<script>
	AllowAddPoi = '<?php echo $AllowAddPoi?>'
Beispiel #16
0
<?php

include "../include/functions.php";
include "../include/db.php";
include "../include/params.php";
include "../include/dictionary2.php";
session_start();
opendb();
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
$yourbrowser1 = (bool) strpos($ua['userAgent'], "Macintosh");
$Allow = getPriv("groupspoi", session("user_id"));
if ($Allow == False) {
    echo header('Location: ../permission/?l=' . $cLang);
}
addlog(41);
?>
<html>
<head>
	<script type="application/javascript">
		lang = '<?php 
echo $cLang;
?>
';
	</script>
	<link rel="stylesheet" type="text/css" href="../style.css">
	<link href="../css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/share.js"></script>
	<script type="text/javascript" src="../js/settings.js"></script>
	<script type="text/javascript" src="../tracking/live.js"></script>
Beispiel #17
0
                sql_updateChannel($myc, $channelpost);
                break;
        }
        print "<h1>Channel " . $channelpost['id'] . " updated</h1>\n";
        reloadUrl('Continue', 'channelslist.php');
        addlog(true, "Channel " . $channelpost['id'] . " updated");
        break;
    case 'delete':
        switch ($dconf['dbtype']) {
            case 'mysql':
                sql_deleteChannel($myc, $channelpost);
                break;
        }
        print "<h1>Channel " . $channelpost['id'] . " deleted</h1>\n";
        reloadUrl('Continue', 'channelslist.php');
        addlog(true, "Channel " . $channelpost['id'] . " deleted");
        break;
}
//
// disconnect from main database
//
switch ($dconf['dbtype']) {
    case 'mysql':
        sql_dodisconnect($myc);
        break;
}
?>

</body>
</html>
Beispiel #18
0
}
$CurrentTime = DlookUP("select to_char(now() + cast('" . ($TimeZone - 1) . " hour' as interval), 'YYYY-MM-DD " . $timeformat . "') DateTime");
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
//echo $yourbrowser;
//exit;
$bojanakola = query("SELECT c1.name engineon, c2.name engineoff, c3.name engineoffpassengeron, c4.name satelliteoff, \r\n\tc5.name taximeteron, c6.name taximeteroffpassengeron, c7.name passiveon, c8.name activeoff\r\n\tfrom users us \r\n\tleft outer join statuscolors c1 on c1.id=us.engineon \r\n\tleft outer join statuscolors c2 on c2.id=us.engineoff \r\n\tleft outer join statuscolors c3 on c3.id=us.engineoffpassengeron \r\n\tleft outer join statuscolors c4 on c4.id=us.satelliteoff \r\n\tleft outer join statuscolors c5 on c5.id=us.taximeteron \r\n\tleft outer join statuscolors c6 on c6.id=us.taximeteroffpassengeron \r\n\tleft outer join statuscolors c7 on c7.id=us.passiveon \r\n\tleft outer join statuscolors c8 on c8.id=us.activeoff \r\n\twhere us.id = " . session("user_id"));
$engineon = pg_fetch_result($bojanakola, 0, "engineon");
$engineoff = pg_fetch_result($bojanakola, 0, "engineoff");
$engineoffpassengeron = pg_fetch_result($bojanakola, 0, "engineoffpassengeron");
$satelliteoff = pg_fetch_result($bojanakola, 0, "satelliteoff");
$taximeteron = pg_fetch_result($bojanakola, 0, "taximeteron");
$taximeteroffpassengeron = pg_fetch_result($bojanakola, 0, "taximeteroffpassengeron");
$passiveon = pg_fetch_result($bojanakola, 0, "passiveon");
$activeoff = pg_fetch_result($bojanakola, 0, "activeoff");
addlog(2);
$pass = dlookup("select md5(password) from users where clientid=" . session("client_id") . " and roleid=2 order by id asc limit 1");
?>
<script>
	AllowAddPoi = '<?php 
echo $AllowAddPoi;
?>
'
	AllowViewPoi = '<?php 
echo $AllowViewPoi;
?>
'
	AllowAddZone = '<?php 
echo $AllowAddZone;
?>
'
Beispiel #19
0
        $currDateTime2E = $dateE;
    }
    if ($currDateTime2 != "") {
        $DateTime2 = date('d-m-Y', strtotime($currDateTime2));
        $DateTime2E = date('d-m-Y', strtotime($currDateTime2E));
    } else {
        $DateTime2 = date('d-m-Y', strtotime($currDateTime1));
        $DateTime2E = $DateTime2;
    }
    addlog(36, dic_('Routes.AllOrdersInPeriod') . " " . $currDateTime2 . ' 00:00:00 ' . dic_("Routes.To") . $currDateTime2E . ' 23:59:59');
} else {
    $currDateTime2 = "";
    $currDateTime2E = "";
    $DateTime2 = "";
    $DateTime2E = "";
    addlog(36, 'Налог со број ' . $tourid);
}
if ($currDateTime2 == "") {
    $currDateTime2 = $cdt1;
}
if ($currDateTime2E == "") {
    $currDateTime2E = $cdt2;
}
$AllowedMaps = "11111";
$cntz = dlookup("select count(*) from pointsofinterest where active='1' and type=2 and clientid=" . Session("client_id"));
//$CurrentTime = DlookUP("select Convert(nvarchar(20), DATEADD(HOUR,(select timeZone from clients where ID=" . Session("client_id") . ") - 1,GETDATE()), 120) DateTime");
$tzone = pg_fetch_result($dsAll, 0, "timezone");
$tzone = $tzone - 1;
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
?>
Beispiel #20
0
            //die();
            //flush();
            $_SESSION['company'] = dlookup("select name from clients where id in (select clientID from users where id=" . pg_fetch_result($ruser, 0, 'id') . " limit 1) limit 1");
            $ShowMessage = 0;
            if ($rem14 == "on") {
                WriteCookies("LogedIn14Days", "on", 14);
                WriteCookies("LogedIn14DaysChecked", "on", 14);
                WriteCookies("user_id", $_SESSION['user_id'], 14);
                WriteCookies("role_id", $_SESSION['role_id'], 14);
                WriteCookies("client_id", $_SESSION['client_id'], 14);
                WriteCookies("user_fullname", $_SESSION['user_fullname'], 14);
                WriteCookies("company", $_SESSION['company'], 14);
            }
        }
        if ($HaveUser == 1) {
            addlog(1, '');
            if ($directlive == '0') {
                header('Location: ../?l=' . $cLang);
            } else {
                header('Location: ../tracking/?l=' . $cLang);
            }
        }
    }
}
closedb();
if ($ShowMessage == 0 && $isActive == 1) {
    $errorString = "style=\"display:none\"";
} else {
    $errorString = "";
}
if (ReadCookies("LogedIn14DaysChecked") == "on") {
Beispiel #21
0
//dim allPOI as integer = dlookup("select count(*) from pinpoints where clientID=" & session("client_id"))
//Dim allPOIs As String = "false"
//If allPOI < 1000 Then allPOIs = "true"
$DefMap = pg_fetch_result($dsAll, 0, "defaultmap");
$currDateTime = new Datetime();
$currDateTime = $currDateTime->format("d-m-Y H:i");
$currDateTime1 = new Datetime();
$currDateTime1 = $currDateTime1->format("d-m-Y");
$AllowedMaps = "11111";
$cntz = dlookup("select count(*) from pointsofinterest where active='1' and type=2 and clientid=" . Session("client_id"));
//$CurrentTime = DlookUP("select Convert(nvarchar(20), DATEADD(HOUR,(select timeZone from clients where ID=" . Session("client_id") . ") - 1,GETDATE()), 120) DateTime");
$tzone = pg_fetch_result($dsAll, 0, "timezone");
$tzone = $tzone - 1;
$ua = getBrowser();
$yourbrowser = (bool) strpos($ua['userAgent'], "iPad");
addlog(33, '');
?>



<style>
	.ui-autocomplete {
		max-height: 100px;
		overflow-y: auto;
		/* prevent horizontal scrollbar */
		overflow-x: hidden;
		/* add padding to account for vertical scrollbar */
		padding-right: 20px;
		width:300px;
	}
</style>
Beispiel #22
0
<div class='content_box'>
  <h3><?php 
echo _("Page Not Found");
?>
</h3>
  <p>
<?php 
$page = getenv("REQUEST_URI");
addlog(LOG_WARN, "  '{$page}' doesn't exist");
sleep(3);
printf(_("Sorry, but %sthat page%s no longer exists."), sprintf('<a href="%s">', $page), "</a>");
?>
  </p>
  <p>
  <center><img width='300' src="/images/tumblbeasts/tb_sign1.png" /><br/><small>
<?php 
printf(_("thanks to %sMatthew Inman%s for the image"), '<a target="_blank" href="http://TheOatmeal.com/">', "</a>");
?>
</small></center>
  </p>
</div>
Beispiel #23
0
$tv1 = '';
if (true) {
    $tv = 'return false;';
    $tv1 = 'opacity: 0.4;';
}
if (!$allowedFM) {
    $fm = 'return false;';
    $fm1 = 'opacity: 0.4;';
}
if (!$allowedrouting) {
    $routes = 'return false;';
    $routes1 = 'opacity: 0.4;';
}
$dsTraceSnooze = query("select snooze from users where id=" . session("user_id"));
$snooze = pg_fetch_result($dsTraceSnooze, 0, "snooze");
addlog(3);
?>
<script>
	AllowUSettings = '<?php 
echo strtolower($AllowUSettings . "");
?>
';
	AllowCSettings = '<?php 
echo strtolower($AllowCSettings . "");
?>
';
	AllowPSettings = '<?php 
echo strtolower($AllowPSettings . "");
?>
';
	lang = '<?php 
Beispiel #24
0
function wsOnClose($clientID, $status)
{
    global $Server, $cVars, $sVars, $rm, $rmBuffer;
    $ip = long2ip($Server->wsClients[$clientID][6]);
    //Client disconnect
    addlog("{$ip} Client ({$clientID}) has disconnected.");
    send("s" . $cVars[$clientID]['name'] . " has left the room.", -$clientID);
    foreach ($rm['p'] as $i => $j) {
        if (isset($j['game'])) {
            send("~D" . pack('n', $clientID), $i, true);
            // Let all connected clients know that we've disconnected
        }
    }
    // Total UNSET//unset($cVars[$clientID],$rm['p'][$clientID],$rmBuffer[$clientID]); // Unsetting values within the array is safe & will not move the indexes
    unset($rm['p'][$clientID]['game'], $rmBuffer[$clientID]);
    // Smart unset
    updateGameRunning();
    $rm['gameRunning'][0] = false;
    foreach ($rm['p'] as $i => $j) {
        if (isset($j['game'])) {
            $rm['gameRunning'][$j['game']] = true;
            break;
        }
    }
    if (isset($sVars['observing']) && in_array($clientID, $sVars['observing'])) {
        if (count($sVars['observing']) == 1) {
            unset($sVars['observing']);
        } else {
            array_splice($sVars['observing'], array_search($clientID, $sVars['observing']));
        }
    }
}
Beispiel #25
0
$alarm = getQUERY("alarm");
$zadrz = getQUERY("zadrz");
$pause1 = getQUERY("pause1");
$pause2 = getQUERY("pause2");
$pause3 = getQUERY("pause3");
$pause4 = getQUERY("pause4");
$pause5 = getQUERY("pause5");
/*Za ZKPelagonija*/
$culid = nnull(getQUERY("culid"), 0);
/*Za ZKPelagonija*/
$totalkm = getQUERY("totalkm");
$totaltime = getQUERY("totaltime");
if ($alarm == "/") {
    $alarm = 0;
}
if ($zadrz == "/") {
    $zadrz = 0;
}
//dim dat() as string = split(datum,"-")
//dim datum1 = dat(2) & "-" & dat(1) & "-" & dat(0)
$tmpDT = new DateTime($datum . ' ' . $vreme);
$tmpDT = $tmpDT->format("Y-m-d H:i:s");
$sqlInsert = "insert into rnalogheder (datetime, VehicleID, DriverID1, DriverID2, DriverID3, StartDate, Name, ClientID, userID, Alarm, toStay, Pause1, Pause2, Pause3, Pause4, Pause5, TotalKm, TotalTime, culid) ";
$sqlInsert .= " Values (now(), " . $vozilo . ", " . $sofer1 . ", " . $sofer2 . ", " . $sofer3 . ", '" . $tmpDT . "', '" . $naslov . "', " . session("client_id") . ", " . session("user_id") . ", " . $alarm . ", " . $zadrz . ", " . $pause1 . ", " . $pause2 . ", " . $pause3 . ", " . $pause4 . ", " . $pause5 . ", " . $totalkm . ", " . $totaltime . ", " . $culid . " )";
//$dsInsert = query($sqlInsert);
$dsInsert = dlookup($sqlInsert . " RETURNING id");
//$dsInsert1 = query("select id from rnalogheder order by id desc limit 1");
//$id = pg_fetch_result($dsInsert1, 0, "id");
addlog(38, dic_('Routes.NewOrderWithNumber') . " " . $dsInsert);
print $dsInsert;
closedb();
Beispiel #26
0
             } else {
                 //Update player
                 $query = $db->execute("update `players` set `exp`=?, `gold`=?, `kills`=?, `hp`=?, `energy`=? where `id`=?", array($player->exp + $expwin, $player->gold + $goldwin, $player->kills + 1, $player->hp, $player->energy - 1, $player->id));
             }
             //Add log message
             $logmsg = sprintf($lang['msg_log_lost'], $player->username);
             addlog($enemy->id, $logmsg, $battlelog, $db);
             //Update enemy (who was defeated)
             $query = $db->execute("update `players` set `hp`=0, `deaths`=? where `id`=?", array($enemy->deaths + 1, $enemy->id));
         } else {
             $output .= "<br />" . $lang['msg_battle_draw'] . "\n";
             $battlelog .= "<br />" . $lang['msg_battle_draw'] . "\n";
             $query = $db->execute("update `players` set `hp`=?, `energy`=? where `id`=?", array($player->hp, $player->energy - 1, $player->id));
             $query = $db->execute("update `players` set `hp`=? where `id`=?", array($enemy->hp, $enemy->id));
             $logmsg = sprintf($lang['msg_log_draw'], $player->username);
             addlog($enemy->id, $logmsg, $battlelog, $db);
         }
     }
     $player = check_user($secret_key, $db);
     //Get new stats
     include "templates/private_header.php";
     echo $output;
     include "templates/private_footer.php";
     break;
 case "search":
     //Check in case somebody entered 0
     $_GET['fromlevel'] = $_GET['fromlevel'] == 0 ? "" : $_GET['fromlevel'];
     $_GET['tolevel'] = $_GET['tolevel'] == 0 ? "" : $_GET['tolevel'];
     //Construct query
     $query = "select `id`, `username`, `hp`, `maxhp`, `level` from `players` where `id`!= ? and ";
     $query .= $_GET['username'] != "" ? "`username` LIKE  ? and " : "";
Beispiel #27
0
$thispage = new IRC();
$thispage->printHeader();
if (!isset($_GET['action'])) {
    $_GET['action'] = "";
}
switch ($_GET['action']) {
    case 'addserver':
        getaddserver();
    case 'showservers':
        showservers();
        break;
    case 'showlogs':
        showlogs();
        break;
    case 'addlog':
        addlog();
        break;
    case 'logsubmit':
        logsubmit();
        break;
    case 'logsubmitlocal':
        logsubmitlocal();
        break;
}
function getaddserver()
{
    global $thispage;
    if (isset($_GET['servername']) && isset($_GET['serveraddr'])) {
        $thispage->addServer($_GET['servername'], $_GET['serveraddr']);
    } else {
        echo "Bad input";
Beispiel #28
0
include "../include/functions.php";
include "../include/params.php";
include "../include/dictionary2.php";
?>


<?php 
header("Content-type: text/html; charset=utf-8");
opendb();
$uid = session('user_id');
$cid = session('client_id');
$Allow = getPriv("vehicles", $uid);
if ($Allow == False) {
    echo header('Location: ../permission/?l=' . $cLang);
}
addlog(42);
?>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>
	<script type="application/javascript"> lang = '<?php 
echo $cLang;
?>
'; </script>
	<link rel="stylesheet" type="text/css" href="../style.css">
    <link rel="stylesheet" type="text/css" href="../live/style.css">
Beispiel #29
0
function process_api_request($function_to_run, $permission_needed)
{
    global $is_logged_in;
    $lock = false;
    try {
        verify_api_request($permission_needed);
        log_api($function_to_run);
        get_user_lock($lock = $is_logged_in);
        $ret = $function_to_run();
    } catch (Exception $e) {
        $error = $e->getMessage();
        addlog(LOG_API, sprintf("[%s] API error: \"%s\": %s: %s", getenv("REMOTE_ADDR"), $error, $function_to_run, file_get_contents("php://input")));
        $ret = array("error" => $error);
    }
    if ($lock) {
        release_lock($lock);
    }
    echo json_encode($ret);
}
Beispiel #30
0
/**
 * mueve un array de ficheros de una carpeta a otra
 * cambiando el nombre de cada uno de ellos como indicado
 *
 * @param string $pathFrom
 * @param array $filenamesFrom
 * @param string $pathTo
 * @param array $filenamesTo
 */
function addFilesToFolder($pathFrom, $filenamesFrom, $pathTo, $filenamesTo, $move = true)
{
    addlog(__FILE__, __FUNCTION__ . ':INIT');
    addlog(__FILE__, __FUNCTION__ . ':pathFrom=' . $pathFrom);
    addlog(__FILE__, __FUNCTION__ . ':filenamesFrom=' . $filenamesFrom);
    addlog(__FILE__, __FUNCTION__ . ':pathTo=' . $pathTo);
    addlog(__FILE__, __FUNCTION__ . ':filenamesTo=' . $filenamesTo);
    if (!is_array($filenamesFrom)) {
        $filenamesFrom = array($filenamesFrom);
    }
    if (!is_array($filenamesTo)) {
        $filenamesTo = array($filenamesTo);
    }
    $top = count($filenamesFrom);
    if ($top != count($filenamesTo)) {
        throw new Exception('los arrays de ficheros tienen longitudes diferentes');
    }
    if ($top == 0) {
        return;
    }
    for ($n = 0; $n < $top; $n++) {
        $filenameTo = $filenamesTo[$n];
        $filenameFrom = $filenamesFrom[$n];
        $filenameFrom = preg_replace('|^/tmp/|', '', $filenameFrom);
        addlog(__FILE__, __FUNCTION__ . ':filenameTo=' . $filenameTo);
        addlog(__FILE__, __FUNCTION__ . ':filenameFrom=' . $filenameFrom);
        addlog(__FILE__, __FUNCTION__ . ':pathTo=' . $pathTo);
        addlog(__FILE__, __FUNCTION__ . ':is_dir(' . $pathTo . ')=' . is_dir($pathTo));
        if (!is_dir($pathTo)) {
            @mkdir($pathTo, 0755, true);
            @chmod($pathTo, 0755);
        }
        addlog(__FILE__, __FUNCTION__ . ':is_file(' . $pathFrom . $filenameFrom . ')=' . is_file($pathFrom . $filenameFrom));
        if (is_file($pathFrom . $filenameFrom)) {
            if (copy($pathFrom . $filenameFrom, $pathTo . $filenameTo)) {
                addlog(__FILE__, __FUNCTION__ . ':copy(' . $pathFrom . $filenameFrom . ',' . $pathTo . $filenameTo . ')');
                if ($move) {
                    unlink($pathFrom . $filenameFrom);
                }
            }
        } else {
            throw new Exception('un fichero no se ha podido procesar');
        }
    }
    addlog(__FILE__, __FUNCTION__ . ':END');
}