$value) { $search[] = $key; $replace[] = $value; } } $text = str_replace($search, $replace, $text); if (!empty($searchrepl['%GID%'])) { $rankingtext = RankImageOrText($searchrepl['%PID%'], $searchrepl['%PLAYERNAME%'], 0, $searchrepl['%GID%'], $searchrepl['%GAMENAME%'], false, $text, NULL); if (!empty($rankingtext)) $text = $rankingtext; } return($text); } function get_values($date_from, $date_to, $pid, $gid, $prefix, &$searchrepl) { $sql_time = (empty($date_from)) ? '' : "AND m.time >= '".date("YmdHis", $week_start)."' and m.time <= '".date("YmdHis", $week_end); $sql_gid = (empty($gid)) ? '' : "AND m.gid = '$gid'"; $sql_order = ($prefix != 'LM') ? '' : 'ORDER BY m.time DESC LIMIT 0,1'; $sql_groupby = ($prefix != 'LM') ? 'p.pid' : '1'; $sql = " SELECT m.time AS gamedate, COUNT(*) AS games, SUM(p.gamescore) as gamescore, SUM(p.frags) AS frags, SUM(p.kills) AS kills, SUM(p.deaths) AS deaths, SUM(p.suicides) as suicides, AVG(p.eff) AS eff, AVG(p.accuracy) AS acc, AVG(p.ttl) AS ttl, SUM(p.gametime) as gametime, SUM(p.flag_capture) as flag_capture, SUM(p.flag_cover) as flag_cover, SUM(p.flag_seal) as flag_cover, SUM(p.flag_assist) as flag_assist, SUM(p.flag_kill) as flag_kill, SUM(p.flag_pickedup) as flag_pickedup, SUM(p.dom_cp) as dom_cp, SUM(p.ass_obj) as ass_obj, SUM(p.spree_double) as spree_double, SUM(p.spree_triple) as spree_triple, SUM(p.spree_multi) as spree_multi, SUM(p.spree_mega) as spree_mega, SUM(p.spree_ultra) as spree_ultra, SUM(p.spree_monster) as spree_monster, SUM(p.spree_kill) as spree_kill, SUM(p.spree_rampage) as spree_rampage, SUM(p.spree_dom) as spree_dom, SUM(p.spree_uns) as spree_uns, SUM(p.spree_god) as spree_god, SUM(p.pu_pads) as pu_pads, SUM(p.pu_armour) as pu_armour, SUM(p.pu_keg) as pu_keg, SUM(p.pu_invis) as pu_invis, SUM(p.pu_belt) as pu_belt, SUM(p.pu_amp) as pu_amp, SUM(p.rank) as rankmovement FROM uts_match AS m, uts_player AS p WHERE m.id = p.matchid $sql_time $sql_gid AND p.pid = '$pid' GROUP BY $sql_groupby $sql_order"; $result = small_query($sql); if (!$result) return; foreach($result as $name => $value) { $name = strtoupper($name); switch($name) { case 'EFF': $value = get_dp($value); break; case 'ACC': $value = get_dp($value); break; case 'TTL': $value = GetMinutes($value); break; case 'GAMETIME': $value = sec2hour($value); break; case 'GAMEDATE': $value = date("Y-m-d H:i", mtimestamp($value)); break; case 'RANKMOVEMENT': $value = ($value >= 0) ? '+'.get_dp($value) : get_dp($value); break; } $searchrepl["%${prefix}_${name}%"] = $value; } } ?> $gid, '%PID%' => $pid, '%GAMENAME%' => $gamename, '%PLAYERNAME%' => $playername, '%PLAYERCOUNTRY%' => strtoupper($playercountry) ); //$search = array('%RT%', '%RN%', '%RP%', '%RI%', '%GN%', '%PN%', '%IT%'); //$replace = array($ranktext, $rank, $points, $img, $gamename, $name, $imageortext); // Add all texts that are used in this pic to one big string // We'll use this string to determine which values the user wants // and hence which we'll have to provide $textstrings = ''; foreach ($pic[$num]['process'] as $process) { if ($process['type'] != 'text') continue; $textstrings .= $process['value']; } $ts = time(); if (strpos($textstrings, '%WEEK_') !== false) { $week_start = mktime(0,0,0, date('m', $ts), date('d', $ts) - date('w', $ts), date('Y', $ts)); $week_end = mktime(23,59,59, date('m', $week_start), date('d', $week_start) + 6, date('Y', $ts)); get_values($week_start, $week_end, $pid, $gid, 'WEEK', $searchrepl); } if (strpos($textstrings, '%LWEEK_') !== false) { $last_week_start = mktime(0,0,0, date('m', $ts), date('d', $ts) - date('w', $ts) - 7, date('Y', $ts)); $last_week_end = mktime(23,59,59, date('m', $last_week_start), date('d', $last_week_start) + 6, date('Y', $ts)); get_values($last_week_start, $last_week_end, $pid, $gid, 'LWEEK', $searchrepl); } if (strpos($textstrings, '%MONTH_') !== false) { $month_start = mktime(0,0,0, date('m', $ts), 1, date('Y', $ts)); $month_end = mktime(23,59,59, date('m', $month_start) + 1, 0, date('Y', $month_start)); get_values($month_start, $month_end, $pid, $gid, 'MONTH', $searchrepl); } if (strpos($textstrings, '%LMONTH_') !== false) { $last_month_start = mktime(0,0,0, date('m', $ts) - 1, 1, date('Y', $ts)); $last_month_end = mktime(23,59,59, date('m', $last_month_start) + 1, 0, date('Y', $last_month_start)); get_values($last_month_start, $last_month_end, $pid, $gid, 'LMONTH', $searchrepl); } if (strpos($textstrings, '%YEAR_') !== false) { $year_start = mktime(0,0,0, 1, 1, date('Y', $ts)); $year_end = mktime(23,59,59, 12, 31, date('Y', $year_start)); get_values($year_start, $year_end, $pid, $gid, 'YEAR', $searchrepl); } if (strpos($textstrings, '%LYEAR_') !== false) { $last_year_start = mktime(0,0,0, 1, 1, date('Y', $ts) - 1); $last_year_end = mktime(23,59,59, 12, 31, date('Y', $last_year_start)); get_values($last_year_start, $last_year_end, $pid, $gid, 'LYEAR', $searchrepl); } if (strpos($textstrings, '%TOTAL_') !== false) { get_values(0, 0, $pid, $gid, 'TOTAL', $searchrepl); } if (strpos($textstrings, '%GTOTAL_') !== false) { get_values(0, 0, $pid, 0, 'GTOTAL', $searchrepl); } if (strpos($textstrings, '%LM_') !== false) { get_values(0, 0, $pid, $gid, 'LM', $searchrepl); } //echo "
"; var_dump($searchrepl); echo "
"; exit; $im = image_create('images/templates/'. $load['template'], $load); $img_width = imagesx($im); $img_height = imagesy($im); if (empty($std['align'])) $std['align'] = 'left'; if (empty($std['angle'])) $std['angle'] = 0; if (empty($std['font'])) $std['font'] = 'microsbe.ttf'; if (empty($std['fontcolor'])) $std['fontcolor'] = 'FFFFFF'; if (empty($std['fontsize'])) $std['fontsize'] = 12; foreach ($pic[$num]['process'] as $process) { switch($process['type']) { case 'text': if (empty($process['align'])) $process['align'] = $std['align']; if (empty($process['font'])) $process['font'] = $std['font']; if (empty($process['fontcolor'])) $process['fontcolor'] = $std['fontcolor']; if (empty($process['fontsize'])) $process['fontsize'] = $std['fontsize']; if (empty($process['angle'])) $process['angle'] = $std['angle']; if (empty($process['x_to'])) $process['x_to'] = $img_width; if (empty($process['y_to'])) $process['y_to'] = $process['y_from']; $text = replace_vars($process['value'], $searchrepl); place_text($im, $process['fontsize'], $process['angle'], $process['x_from'], $process['x_to'], $process['y_from'], $process['y_to'], $process['fontcolor'], 'images/fonts/'.$process['font'], $process['align'], $text); break; default: die("Don't know how to process: ". $process['type']); } } output_image($im, $output); ?>