Beispiel #1
0
 function __construct($width = 400, $height = 300, $name = '示例图片', $data = array(), $beginValueY = 0, $everySetpY = 0, $beginValueX = 0, $everyStepX = 0, $imageType = 'image/jpeg', $fontSize = 10)
 {
     $this->width = $width;
     $this->height = $height;
     $this->name = $name;
     $this->data = $data;
     $this->imageType = $imageType;
     $this->fontSize = $fontSize;
     $minMaxArray = getMinMax($this->data);
     $this->min = $minMaxArray['min'];
     $this->max = $minMaxArray['max'];
     $this->beginValueX = $beginValueX;
     $this->beginValueY = $beginValueY;
     $this->everyStepX = $everyStepX;
     $this->everySetpY = $everySetpY;
     $this->image = imagecreatetruecolor($this->width, $this->height);
     $this->bgColor = imagecolorallocate($this->image, 255, 255, 255);
     imagefill($this->image, 0, 0, $this->bgColor);
     $this->textColor = imagecolorallocate($this->image, 0, 0, 0);
 }
Beispiel #2
0
    $sqlQuery = "SELECT zone1, zone2, zone3, zone4, timestamp FROM temps WHERE timestamp >= date('now','-6 day')";
    $result = $file_db->query($sqlQuery);
    $otherData[] = array('Date', 'Zone1', 'Zone2', 'Zone3', 'Zone4');
    foreach ($result as $row) {
        //$f[] = $row[0];
        //$f[] = array($row[4], $row[0], $row[1], $row[2], $row[3]);
        $otherData[] = array($row[4], floatval($row[0]), floatval($row[1]), floatval($row[2]), floatval($row[3]));
    }
    //$otherData[] = array('June 25', 12.25);
    //$otherData[] = array('June 26', 14.25);
    echo json_encode($otherData);
}
function LogWhoConnected()
{
    //Get the IP address of the connecting device
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    //Write the above IP address and DateTime stamp to Log.txt file.
    $file = 'Log.txt';
    $logString = "" . date("Y-m-d H:i:s") . " " . $ip . "\r";
    // Write the contents back to the file
    file_put_contents($file, $logString, FILE_APPEND);
}
//getInfoFor();
getMinMax();
LogWhoConnected();
Beispiel #3
0
function profile($id)
{
    $games = file_get_contents('games.log');
    $games = explode("\n", $games);
    $stats = array('games' => 0, 'wins' => 0, 'losses' => 0, 'wins_goalee' => 0, 'losses_goalee' => 0, 'wins_midfield' => 0, 'losses_midfield' => 0, 'skunk_wins' => 0, 'skunk_losses' => 0, 'best_partner' => 0, 'worst_partner' => 0, 'best_opponent' => 0, 'worst_opponent' => 0, 'winning_score' => 0, 'losing_score' => 0);
    $partners = array();
    $opponents = array();
    $scores = array();
    $winningStreak = $losingStreak = $currentStreak = 0;
    $lastResult = null;
    foreach ($games as $game) {
        if (empty($game)) {
            continue;
        }
        $game = explode("\t", $game);
        if (count($game) != 4) {
            continue;
        }
        $teams = array(explode(",", $game[1]), explode(",", $game[2]));
        if (!in_array($id, $teams[0]) && !in_array($id, $teams[1])) {
            continue;
        }
        if (count($teams[0]) != 2 || count($teams[1]) != 2) {
            continue;
        }
        $stats['games']++;
        $team = in_array($id, $teams[0]) ? 0 : 1;
        $partnerId = $teams[$team][0] == $id ? $teams[$team][1] : $teams[$team][0];
        $result = explode(",", $game[3]);
        $winningResult = $losingResult = $result;
        rsort($winningResult);
        sort($losingResult);
        $winningResult = join(':', $winningResult);
        $losingResult = join(':', $losingResult);
        $winningTeam = (count($result) == 1 ? $result[0] : ($result[0] > $result[1] ? 1 : 2)) - 1;
        $isWinner = $winningTeam == $team;
        $stats[$isWinner ? 'wins' : 'losses']++;
        $isGoalee = $id == $teams[$team][0];
        $stats[$isWinner ? $isGoalee ? 'wins_goalee' : 'wins_midfield' : ($isGoalee ? 'losses_goalee' : 'losses_midfield')]++;
        if ($isWinner !== $lastResult) {
            $currentStreak = 0;
            $lastResult = $isWinner;
        }
        $currentStreak++;
        if ($isWinner && $winningStreak < $currentStreak) {
            $winningStreak = $currentStreak;
        }
        if (!$isWinner && $losingStreak < $currentStreak) {
            $losingStreak = $currentStreak;
        }
        if (count($result) == 2) {
            if ($isWinner && $result[1 - $team] == 0) {
                $stats['skunk_wins']++;
            }
            if (!$isWinner && $result[$team] == 0) {
                $stats['skunk_losses']++;
            }
            $normalizedResult = $isWinner ? $winningResult : $losingResult;
            $scores[$normalizedResult] = (isset($scores[$normalizedResult]) ? $scores[$normalizedResult] : 0) + ($isWinner ? 1 : -1);
        }
        $partners[$partnerId] = (isset($partners[$partnerId]) ? $partners[$partnerId] : 0) + ($isWinner ? 1 : -1);
        $opponents[$teams[1 - $team][0]] = (isset($opponents[$teams[1 - $team][0]]) ? $opponents[$teams[1 - $team][0]] : 0) + ($isWinner ? 1 : -1);
        $opponents[$teams[1 - $team][1]] = (isset($opponents[$teams[1 - $team][1]]) ? $opponents[$teams[1 - $team][1]] : 0) + ($isWinner ? 1 : -1);
    }
    if ($lastResult && $winningStreak < $currentStreak) {
        $winningStreak = $currentStreak;
    }
    if (!$lastResult && $losingStreak < $currentStreak) {
        $losingStreak = $currentStreak;
    }
    $stats['best_partner'] = getMinMax($partners, true);
    $stats['worst_partner'] = getMinMax($partners, false);
    $stats['best_opponent'] = getMinMax($opponents, true);
    $stats['worst_opponent'] = getMinMax($opponents, false);
    $stats['winning_score'] = getMinMax($scores, true);
    $stats['losing_score'] = getMinMax($scores, false);
    $stats['winning_streak'] = $winningStreak;
    $stats['losing_streak'] = $losingStreak;
    return $stats;
}
Beispiel #4
0
require_once dirname(__FILE__) . "/../include/common.inc.php";
//加载线路
if ($dopost == 'getlinelist') {
    $offset = ($curpage - 1) * $pagesize;
    //  这里处理成目的地可多选的操作.
    if (isset($dest_id) && !empty($dest_id)) {
        $dest_id_arr = explode(',', $dest_id);
        $j = 1;
        foreach ($dest_id_arr as $did) {
            $flag = $j == 1 ? ' and ' : 'or';
            $where .= " {$flag} FIND_IN_SET({$did},a.kindlist)";
            $j++;
        }
    }
    if (!empty($priceid) && $priceid != 0) {
        $pricearr = getMinMax($priceid);
        //取得价格范围的最小与最大值 .
        $where .= " and a.price >= {$pricearr['min']} and a.price <= {$pricearr['max']} ";
    }
    //按名称搜索
    if (!empty($searchkey) || $searchkey != 0) {
        $where .= " and title like '%{$searchkey}%'";
    }
    if (!empty($attrlist)) {
        $where .= getAttWhere($attrlist);
    }
    $sql = "select * from #@__line a where a.ishidden=0 {$where} ";
    $sql .= " limit {$offset},{$pagesize}";
    debug($sql);
    $arr = $dsql->getAll($sql);
    $i = 1;