$sql = 'SELECT skin_id, skin_name, skin_author, gfxpack_link, skinpreview_link, skin_desc FROM skins'; if (($q_skins = $db->query($sql)) === false) { message(DATABASE_ERROR, 'Could not query skin data'); } $main_html .= ' <span style="font-size: 14px;">' . constant($game->sprache("TEXT8")) . '</span><br><br><br> <table border="0" width="60%"> '; while ($cur_skin = $db->fetchrow($q_skins)) { $main_html .= ' <tr> <td valign="top"> <b>' . $cur_skin['skin_name'] . '</b> ' . constant($game->sprache("TEXT9")) . ' <i>' . $cur_skin['skin_author'] . '</i><br><br>' . $cur_skin['skin_desc'] . '<br><br><a href="' . TPL_MGR_EXE . '?change_skin=' . $cur_skin['skin_id'] . '">' . constant($game->sprache("TEXT10")) . '</a><br><a href="' . $cur_skin['gfxpack_link'] . '">' . constant($game->sprache("TEXT11")) . '</a> </td> <td width="150"> <img src="' . $cur_skin['skinpreview_link'] . '"> </td>
$map_data = '<map name="detail_map">'; $im = imagecreatetruecolor(162 * $size, 162 * $size); imagecolorallocatealpha($im, 0, 0, 0, 0); $color[1] = imagecolorallocatealpha($im, 90, 64, 64, 0); $color[2] = imagecolorallocatealpha($im, 128, 64, 64, 0); $color[3] = imagecolorallocatealpha($im, 196, 64, 64, 0); $color[4] = imagecolorallocatealpha($im, 96, 96, 96, 0); $color[5] = imagecolorallocatealpha($im, 255, 0, 0, 20); drawMapGrid($im, $size); $sql = ' SELECT s.system_id, s.system_name, s.sector_id, s.system_x, s.system_y FROM starsystems s'; if (!($q_systems = $db->query($sql))) { message(DATABASE_ERROR, 'Could not query starsystems data'); } while ($system = $db->fetchrow($q_systems)) { $glob_systems[$system['system_id']] = $system; } $q_planets = $db->query('SELECT system_id FROM planets WHERE planet_owner=0 GROUP BY system_id'); while ($planet = $db->fetchrow($q_planets)) { $system = $glob_systems[$planet['system_id']]; $px = getSystemCoords($system, $size); $px_x = $px[0]; $px_y = $px[1]; if ($size > 2) { imagefilledrectangle($im, $px_x, $px_y, $px_x + $size - 2, $px_y + $size - 2, $color[5]); $map_data .= '<area href="index.php?a=tactical_cartography&system_id=' . encode_system_id($system['system_id']) . '" target=_mapshow shape="rect" coords="' . $px_x . ',' . $px_y . ', ' . ($px_x + $size - 2) . ', ' . ($px_y + $size - 2) . '" title="' . $system['system_name'] . '"> '; } else { imagefilledrectangle($im, $px_x - 1, $px_y - 1, $px_x + $size - 2, $px_y + $size - 2, $color[5]); $map_data .= '<area href="index.php?a=tactical_cartography&system_id=' . encode_system_id($system['system_id']) . '" target=_mapshow shape="rect" coords="' . ($px_x - 1) . ',' . ($px_y - 1) . ', ' . ($px_x + $size - 2) . ', ' . ($px_y + $size - 2) . '" title="' . $system['system_name'] . '">
--> </style> <body bgcolor="#000000" text="#DDDDDD" background="/gfx/bg_stars1.gif"> <table class="style_outer" width="550" align="center" border="0" cellpadding="2" cellspacing="2"> <tr> <td> <table class="style_inner" width="550" align="center" border="0" cellpadding="2" cellspacing="2"> '; if (isset($_GET['user'])) { $user_id = (int) $_GET['user']; echo '<td> </td><td><font size="3"><b>' . constant($game->sprache("TEXT1")) . '</b></font></td><td><font size="3"><b>' . get_username_by_id($user_id) . '</b></font></td></tr><tr><td> </td></tr><tr><td></td><td width="235"><b>' . constant($game->sprache("TEXT2")) . '</b></td><td width="200"><b>' . constant($game->sprache("TEXT3")) . '</b></td><td width="70"><b>' . constant($game->sprache("TEXT4")) . '</b></td></tr>'; $config = $db->queryrow('SELECT * FROM config'); $sql = 'SELECT * FROM ship_trade WHERE user = '******' AND end_time > ' . $config['tick_id'] . ''; if (!($q_tradedata = $db->query($sql))) { message(DATABASE_ERROR, 'Could not query tradedata'); } while ($tradedata = $db->fetchrow($q_tradedata)) { echo '<tr><td width="55" align="center">[<a onclick="opener.window.location=this.href;self.close();return false" href="/game/index.php?a=trade&view=view_bidding_detail&id=' . $tradedata['id'] . '">' . constant($game->sprache("TEXT5")) . '</a>]</td><td>' . $tradedata['header'] . '</td><td><img src="' . PROXY_GFX_PATH . '/skin1/menu_metal_small.gif"> ' . $tradedata['resource_1'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_mineral_small.gif"> ' . $tradedata['resource_2'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_latinum_small.gif"> ' . $tradedata['resource_3'] . ' <br><img src="' . PROXY_GFX_PATH . '/skin1/menu_unit1_small.gif"> ' . $tradedata['unit_1'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_unit2_small.gif"> ' . $tradedata['unit_2'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_unit3_small.gif"> ' . $tradedata['unit_3'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_unit4_small.gif"> ' . $tradedata['unit_4'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_unit5_small.gif"> ' . $tradedata['unit_5'] . ' <img src="' . PROXY_GFX_PATH . '/skin1/menu_unit6_small.gif"> ' . $tradedata['unit_6'] . '</td><td>' . Zeit(TICK_DURATION * ($tradedata['end_time'] - $config['tick_id'])) . '</td></tr>'; } } else { echo constant($game->sprache("TEXT6")); } echo '</table></td></tr></table></body> </html>'; $db->close();
} $sdl->finish_job('Reset New Registration Count'); // ####################################################################################### // ####################################################################################### // Check sitting abuse and lock'em $sdl->start_job('Sitting abuse check'); $sql = 'SELECT user_id,user_name,num_hits,num_sitting FROM user WHERE (num_sitting/(num_hits+1))>0.35 AND (num_sitting>50 OR (num_hits<10 AND num_sitting>30))'; if (($result = $db->query($sql)) === false) { $sdl->log('<b>Error:</b> cannot select user data!'); } else { if (!$db->query('UPDATE user SET num_hits=0, num_sitting=0')) { $sdl->log('<b>Error:</b> cannot reset sitting information!'); } while ($user = $db->fetchrow($result)) { /* 25/08/14 - AC: According to the used query, num_sitting cannot be zero instead num_hits could be */ $val = $user['num_sitting'] / ($user['num_hits'] + 1); /* 24/04/08 - AC: Add language translation based on user language */ switch ($user['language']) { case 'GER': $text = 'fast ausschließlich gesittet'; if ($val < 0.8) { $text = 'stark übermäßig gesittet'; } if ($val < 0.6) { $text = 'Übermäßig gesittet'; } if ($val < 0.45) { $text = 'etwas zuviel gesittet'; }
$sql = 'SELECT s.*,u.user_race, p.planet_type,p.research_4,p.building_queue, p.building_1,p.building_2,p.building_3,p.building_4, p.building_5,p.building_6,p.building_7,p.building_8, p.building_9,p.building_10,p.building_11,p.building_12 FROM (`scheduler_instbuild` s) LEFT JOIN (planets p) ON s.planet_id = p.planet_id LEFT JOIN (user u) ON u.user_id=p.planet_owner WHERE p.building_queue <> 0'; //echo "First query:\n".$sql."\n"; if (($q_inst = $db->query($sql)) === false) { echo "Error: could not query scheduler instbuild data!\n"; } else { if ($db->num_rows() > 0) { $n_instbuild = 0; while ($build = $db->fetchrow($q_inst)) { $building_name = 'building_' . ($build['installation_type'] + 1); echo "Building being built : " . $build['installation_type'] . " (name: " . $building_name . ") Level: " . $build[$building_name] . "\n"; echo "Building will be built: " . ($build['building_queue'] - 1) . "\n"; // In order to calculate times correctly, I need to consider also the building // being built at the moment if ($build['installation_type'] == $build['building_queue'] - 1) { $build[$building_name]++; echo "New level: " . $build[$building_name] . "\n"; } $time = GetBuildingTimeTicks($build['building_queue'] - 1, $build, $build['user_race']); // Insert the queued building using the new method $sql = 'INSERT INTO scheduler_instbuild (installation_type,planet_id,build_start,build_finish) VALUES ("' . ($build['building_queue'] - 1) . '", "' . $build['planet_id'] . '", "' . $build['build_finish'] . '",
if ($res > 0) { $sdl->log('Extra-Optimal Range Upgrade Planet this time: ' . $res); } $sdl->finish_job('Extra-Optimal Range Upgrade Planet Step'); // ######################################################################################## // ######################################################################################## // Building Scheduler $sdl->start_job('Building Scheduler'); $sql = 'SELECT planet_id,installation_type FROM scheduler_instbuild WHERE build_finish <= ' . $ACTUAL_TICK; if (($q_inst = $db->query($sql)) === false) { $sdl->log('<b>Error:</b> Could not query scheduler instbuild data! - SKIPPED'); } else { if ($db->num_rows() > 0) { while ($build = $db->fetchrow($q_inst)) { $recompute_static = in_array($build['installation_type'], array(1, 2, 3, 11)) ? 1 : 0; $sql = 'UPDATE planets SET building_' . ($build['installation_type'] + 1) . ' = building_' . ($build['installation_type'] + 1) . ' + 1, recompute_static = ' . $recompute_static . ' WHERE planet_id = ' . $build['planet_id']; if (!$db->query($sql)) { $sdl->log('<b>Error:</b> Query sched_instbuild @ planets failed! - CONTINUED'); } } $sql = 'DELETE FROM scheduler_instbuild WHERE build_finish <= ' . $ACTUAL_TICK; if (!$db->query($sql)) { $sdl->log('<b>Error:</b> Could not delete instbuild data - CONTINUED'); } unset($build);
/** * Function to retrieve the latest posts from the forums */ function display_lastposts() { global $game, $config; $dir = $config['forum_path']; $limit = $config['forum_show']; $f_url = $config['forum_url']; if ($limit == 0) { return; } include $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/conf_global.php"; // Database connection $fdb = new sql($INFO['sql_host'], $INFO['sql_database'], $INFO['sql_user'], $INFO['sql_pass']); // create sql-object for db-connection // Filtered query $qr = $fdb->query("SELECT t.title as t_title, " . "t.starter_id as t_starter, " . "t.starter_name as t_starter_n, " . "t.forum_id as forumid, " . "FROM_UNIXTIME((t.start_date), '%d.%m.%y') as start_d, " . "t.posts as t_posts, " . "t.tid as t_id, " . "t.last_post as t_last_posted, " . "t.last_poster_id as t_last, " . "t.last_poster_name as t_name, " . "p.post as p_post, " . "g.g_title " . "FROM nonsolotaku_topics t, " . "nonsolotaku_posts p, " . "nonsolotaku_members m, " . "nonsolotaku_groups g " . "WHERE topic_id=tid && " . "new_topic=1 && " . "m.member_id=t.starter_id && " . "m.member_group_id=g.g_id && " . "t.approved=1 && " . "t.forum_id<>'15' && " . "t.forum_id<>'37' && " . "t.forum_id<>'12' " . "ORDER BY t_last_posted DESC " . "LIMIT 0, " . $limit); $game->out(' <table class="style_outer" border="0" cellpadding="2" cellspacing="2" width="100%"> <tr> <td align="center"><span class="sub_caption">' . constant($game->sprache("TEXT18")) . '</span><br><br> <table border="0" cellpadding="5" cellspacing="5" width="100%" class="style_inner"> '); // calculating the number of replies $nrows = $fdb->num_rows($qr); for ($i = 0; $i < $nrows; $i++) { $row = $fdb->fetchrow($qr); $author_id = $row['t_starter']; $author = $row['t_starter_n']; $topic_title = $row['t_title']; $topic_id = $row['t_id']; $num_posts = $row['t_posts']; $last_author = $row['t_name']; $last_id = $row['t_last']; $creation_date = $row['start_d']; // Date and hour of last post $posttime = strftime("%d/%m/%y, %H:%M", $row['t_last_posted']); $game->out(' <tr> <td valign="top"> <a href="' . $f_url . '?showtopic=' . $topic_id . '&view=getnewpost" target=_blank><span class="text_large">' . $topic_title . '</span></a><br> <b>' . constant($game->sprache("TEXT19")) . '</b> <a href="' . $f_url . '?showuser='******'" target=_blank>' . $author . '</a><br/> <b>' . constant($game->sprache("TEXT20")) . '</b> ' . $num_posts . '<br> <b>' . constant($game->sprache("TEXT21")) . '</b> <a href="' . $f_url . '?showuser='******'" target=_blank>' . $last_author . '</a><br> <b>' . constant($game->sprache("TEXT22")) . '</b> ' . $posttime . ' </td> </tr>'); } $game->out(' </table> </td> </tr> </table> '); $fdb->close(); }
$pdf = new PDF(); //$pdf->SetAuthor($game->player['user_name']); $pdf->SetAuthor('http://www.stfc.it'); $pdf->SetTitle($config['site_url']); $pdf->AddPage(); $pdf->SetFont('arial', '', 16); $pdf->SetTextColor(250, 0, 0); $pdf->Cell(0, 10, $userrank, 'B', 1); $pdf->Ln(0.15); $pdf->SetFont('Arial', 'I', 8); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(0, 7, $created . date('d.m.y H:i', time()) . '', 0, 'R'); $pdf->SetAutoPageBreak(true, 15.0); $pdf->SetFont('arial', '', 12); $pdf->WriteHTML($anfang); while (($user = $db->fetchrow($listquery)) != false) { $gen = '<tr><td>' . $rang_user . '.</td><td>' . $user['user_name'] . '</td><td>' . (!empty($user['user_alliance']) ? '' . get_alliance_tag($user['user_alliance']) . '' : '') . '</td><td>' . $user['user_planets'] . '</td><td>' . $user['user_points'] . '</td><td>' . ($user['user_honor'] < 1 ? '-' : $user['user_honor']) . '</td></tr>'; $pdf->WriteHTML($gen); $rang_user++; } $pdf->WriteHTML($ende); $pdf->Output(); } if ($_GET['action'] == 'alliance') { $order_str = 'alliance_points DESC'; if ($order == 'points') { $order_str = 'alliance_points DESC'; } elseif ($order == 'planets') { $order_str = 'alliance_planets DESC'; } elseif ($order == 'honor') { $order_str = 'alliance_honor DESC';
imageline($im, $t * $size, 0, $t * $size, 162 * $size, $grid); } else { imageline($im, 0, $t * $size, 162 * $size, $t * $size, $grid3); imageline($im, $t * $size, 0, $t * $size, 162 * $size, $grid3); } } } // Quadrant grid imageline($im, 0, 81 * $size, 162 * $size, 81 * $size, $grid2); imageline($im, 81 * $size, 0, 81 * $size, 162 * $size, $grid2); // Read ALL starsystems from the DB $sql = 'SELECT s.system_id, s.system_name, s.sector_id, s.system_x, s.system_y FROM starsystems s'; if (!($q_systems = $db->query($sql))) { message(DATABASE_ERROR, 'Could not query starsystems data'); } while ($system = $db->fetchrow($q_systems)) { $glob_systems[$system['system_id']] = $system; } // Select all members of the alliance $q_members = $db->query('SELECT user_id,user_name FROM user WHERE user_alliance=' . $alliance['alliance_id']); $i = 0; while ($member = $db->fetchrow($q_members)) { $members[$i] = $member['user_id']; $names[$members[$i]] = $member['user_name']; $i++; } // Select all starsystems of the alliance $q_planets = $db->query('SELECT system_id FROM planets WHERE planet_owner IN (' . implode(',', $members) . ') GROUP BY system_id'); // Select all planets of the alliance that have at least a fleet in the orbit // NOTE: Here we can do some optimization, SELECTing fleets before doing this one $q_planets1 = $db->query('SELECT system_id, planet_id, planet_name FROM planets WHERE planet_owner IN (' . implode(',', $members) . ') AND planet_id IN (SELECT planet_id FROM ship_fleets WHERE user_id IN (' . implode(',', $members) . '))');
if (($handle = @fopen($image_url, "rb")) != true) { $map_data = '<map name="detail_map">'; $im = imagecreatetruecolor(162 * $size, 162 * $size); imagecolorallocatealpha($im, 0, 0, 0, 0); $color[1] = imagecolorallocatealpha($im, 90, 64, 64, 0); $color[2] = imagecolorallocatealpha($im, 128, 64, 64, 0); $color[3] = imagecolorallocatealpha($im, 196, 64, 64, 0); $color[4] = imagecolorallocatealpha($im, 96, 96, 96, 0); $color[5] = imagecolorallocatealpha($im, 255, 0, 0, 20); drawMapGrid($im, $size); // Obtain ALL the starsystems $sql = 'SELECT s.system_id, s.system_name, s.sector_id, s.system_x, s.system_y FROM starsystems s'; if (!($q_systems = $db->query($sql))) { message(DATABASE_ERROR, 'Could not query starsystems data'); } while ($system = $db->fetchrow($q_systems)) { $glob_systems[$system['system_id']] = $system; } // Select known systems /*$sql = 'SELECT pl.system_id FROM (planets pl) LEFT JOIN (planet_details pd) ON pl.system_id = pd.system_id LEFT JOIN (user u) ON pl.planet_owner = u.user_id WHERE pd.user_id = "'.$game->player['user_id'].'" AND pd.log_code = 500 OR u.user_alliance = '.$game->player['user_alliance'].' GROUP BY pl.system_id';*/ $sql = 'SELECT system_id FROM `starsystems_details` WHERE user_id = ' . $game->player['user_id']; $systems = $db->query($sql); while ($system = $db->fetchrow($systems)) { $known_systems[$system['system_id']] = $system; }
do something ... during error / message: $sdl->log('...'); best also - before, so it's apart from the other messages, also: $sdl->log('- this was not true'); $sdl->finish_job('Mine Job'); // terminates the timer */ $sdl->start_job('Recalculate resources'); $db->query('UPDATE planets SET recompute_static=1'); $sdl->finish_job('Recalculate resources'); $sdl->start_job('Recalculate security forces'); $sql = 'SELECT u.user_id FROM user u WHERE u.user_active=1'; $count = 0; if (!($q_user = $db->query($sql))) { $sdl->log('<b>Error:</b> could not query user data'); } while ($user = $db->fetchrow($q_user)) { $sql = 'SELECT planet_id, planet_owner_enum FROM planets WHERE planet_owner=' . $user['user_id'] . ' ORDER BY planet_owned_date ASC, planet_id ASC'; if (!($q_planet = $db->query($sql))) { $sdl->log('<b>Error:</b> could not query user data'); } $i = 0; while ($planet = $db->fetchrow($q_planet)) { if ($planet['planet_owner_enum'] != $i) { $count++; } $i++; $count2++; } if (!$db->query('SET @i=0')) { $sdl->log('<b>Error:</b> could not set sql iterator variable for planet owner enum! SKIP'); }
// create sql-object for db-connection exec('cd ' . $game_path . 'sig_tmp/; rm -f *.jpg'); $rank_honor = array(); $rank_honor[0] = 0; $rank_honor[1] = 25; $rank_honor[2] = 50; $rank_honor[3] = 150; $rank_honor[4] = 250; $rank_honor[5] = 400; $rank_honor[6] = 700; $rank_honor[7] = 1200; $rank_honor[8] = 2000; $rank_honor[9] = 5000; $userqry = $db->query('SELECT u.user_name, u.user_planets, u.user_points,u.user_honor, u.user_race,u.user_rank_points,a.alliance_name, u.language FROM (user u) LEFT JOIN (alliance a) ON a.alliance_id=u.user_alliance WHERE u.user_enable_sig=1 AND user_points>0'); $passed = $total = 0; while (($player_data = $db->fetchrow($userqry)) == true) { if (!isset($player_data['alliance_name'])) { $player_data['alliance_name'] = '-'; } $rank_nr = 1; if ($player_data['user_honor'] >= $rank_honor[0]) { $rank_nr = 1; } if ($player_data['user_honor'] >= $rank_honor[1]) { $rank_nr = 2; } if ($player_data['user_honor'] >= $rank_honor[2]) { $rank_nr = 3; } if ($player_data['user_honor'] >= $rank_honor[3]) { $rank_nr = 4;
$mines_upgraded = 0; $miners = array(); $mines_level = array(); $borg = new NPC($db, $sdl); $borg->LoadNPCUserData(BORG_USERID); // We need many infos here, for StartBuild() function $sql = 'SELECT planet_id, planet_type, building_1, building_2, building_3, building_4, building_5, building_6, building_7, building_8, building_9, building_10, building_11, building_12, building_13, resource_1, resource_2, resource_3, resource_4 research_3, research_4, workermine_1, workermine_2, workermine_3 FROM planets WHERE planet_owner = ' . BORG_USERID; $borg_planets = $db->query($sql); while ($planet = $db->fetchrow($borg_planets)) { // If we have at least a workers slot if ($planet['resource_4'] > 100) { $mine = 0; $max_reached = 0; $miners_updated = false; $miners[0] = $planet['workermine_1']; $miners[1] = $planet['workermine_2']; $miners[2] = $planet['workermine_3']; $workers = $planet['resource_4']; $mines_level[0] = $planet['building_2']; $mines_level[1] = $planet['building_3']; $mines_level[2] = $planet['building_4']; while ($workers > 100 && $max_reached < 3) { // If there is space for new workers if ($miners[$mine] < $mines_level[$mine] * 100 + 100) {