<?php checkFile($clients_file); if (file_exists($clients_file)) { $clients_data = file($clients_file); } if (!isset($clients_data)) { echo "<FONT COLOR=red>Server is down or updating ... Please try again later !</FONT>"; exit; } loadUsageData(); //___________________________________________________________________________________________________ $user_shareinfo = false; $lastUsername = ""; foreach ($clients_data as $currentline) { $inceput1 = substr($currentline, 0, 1); $inceput2 = substr($currentline, 1, 2); if (strstr($currentline, "| Shareinfo")) { $user_shareinfo = true; } if ($user_shareinfo == false && $inceput1 == "|" && $inceput2 != " U") { $active_client = explode("|", $currentline); $ac_Username = trim($active_client[1]); $ac_IP = trim($active_client[2]); $ac_Connected = trim($active_client[3]); $ac_Idle = trim($active_client[4]); $ac_ECM = trim($active_client[5]); $ac_EMM = trim($active_client[6]); $ac_Version = trim($active_client[7]); $ac_LastShare = trim($active_client[8]); $ac_EcmTime = "";
function saveUsageData($clients_data) { $saveTime = time(); global $usage_file; global $UsageUsers; loadUsageData(); $modificat = false; foreach ($clients_data as $currentline) { $inceput1 = substr($currentline, 0, 1); $inceput2 = substr($currentline, 1, 2); if (strstr($currentline, "| Shareinfo")) { break; } if ($inceput1 == "|" && $inceput2 != " U") { $active_client = explode("|", $currentline); $ac_Username = trim($active_client[1]); $ac_IP = trim($active_client[2]); $ac_Connected = trim($active_client[3]); $ac_Idle = trim($active_client[4]); $ac_ECM = trim($active_client[5]); $ac_EMM = trim($active_client[6]); $ac_Version = trim($active_client[7]); $ac_LastShare = trim($active_client[8]); $ac_EcmTime = ""; if (isset($active_client[9])) { $ac_EcmTime = trim($active_client[9]); } list($acEcm, $acEcmOk) = explode("(", $ac_ECM); list($acEcmOk, $temp) = explode(")", $acEcmOk); list($acEmm, $acEmmOk) = explode("(", $ac_EMM); list($acEmmOk, $temp) = explode(")", $acEmmOk); $indexECM = formula_usage($ac_Connected, $ac_ECM); list($zile, $rest) = explode("d ", $ac_Connected); list($ore, $minute, $secunde) = explode(":", $rest); $minuteConectat = 1 + $zile * 24 * 60 + $ore * 60 + $minute; $timediff = 0; if ($UsageUsers[$ac_Username]["time"] != "") { $timediff = $saveTime - $UsageUsers[$ac_Username]["time"]; } $minuteDiff = (int) intval($timediff / INT_MINUTE); $SaveIndexECM = $UsageUsers[$ac_Username]["usage"]; list($lastIndexEcm, $averageIndexEcm) = explode(".", $SaveIndexECM, 2); if ($minuteConectat < $minuteDiff) { if (isset($averageIndexEcm) && $averageIndexEcm != "") { $averageIndexEcm = (int) (($lastIndexEcm + $averageIndexEcm * 3) / 4); } else { if (isset($lastIndexEcm) && $lastIndexEcm != "") { $averageIndexEcm = $indexECM; } } } $lastIndexEcm = $indexECM; $UsageUsers[$ac_Username]["usage"] = $lastIndexEcm . "." . $averageIndexEcm; $UsageUsers[$ac_Username]["time"] = $saveTime; $UsageUsers[$ac_Username]["ip"] = $ac_IP; $modificat = true; } } if ($modificat == true) { $fp = @fopen($usage_file, "w"); fwrite($fp, "savetime|" . $saveTime . "|" . "\n"); foreach ($UsageUsers as $User => $Usage) { if ($User != "savetime") { fwrite($fp, $User . "/" . $Usage["ip"] . "|" . $Usage["time"] . "|" . $Usage["usage"] . "\n"); } } fclose($fp); } }