1. Список говнокодов пользователя tooyz

    Всего: 1

  2. PHP / Говнокод #20238

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    function setLastHandshake ($carID) {
    	$HsList = json_decode(file_get_contents('carconnection.txt'), 1);
    	if ($HsList == "null" || $HsList == null) {
    		$HsList = json_decode("[]");
    	}
    	$carCount = count($HsList);
    	$i = 0;
    	foreach ($HsList as &$row) {
    		if ($row['car'] == $carID) {
    			$row['lastHS'] = (string)time();
    			break;
    		}
    		else {
    		$i++;
    		}
    		if ($i == $carCount) {
    			$HsList[] = array('car' => (string)$carID, 'lastHS' => (string)time());
    		}
    	}
    	if ($HsList == "null" || $HsList == null) {
    		return -1;
    	}
    	$f = fopen('carconnection.txt', 'w');
    	fwrite($f, json_encode($HsList));
    }

    tooyz, 20 Июня 2016

    Комментарии (1)