コード例 #1
0
ファイル: upgrade.php プロジェクト: BackupTheBerlios/flushcms
         $inc = 0;
         if ($row = $db->sql_fetchrow($result)) {
             do {
                 $sql = "UPDATE " . TOPICS_TABLE . " \n\t\t\t\t\t\t\tSET topic_first_post_id = " . $row['first_post_id'] . " \n\t\t\t\t\t\t\tWHERE topic_id = " . $row['topic_id'];
                 query($sql, "Couldn't update topic first post id in topic :: {$topic_id}");
                 $inc++;
                 if ($inc == $per_pct) {
                     print ".";
                     flush();
                     $inc = 0;
                 }
             } while ($row = $db->sql_fetchrow($result));
         }
         print " <span class=\"ok\"><b>OK</b></span><br />\n";
     }
     lock_tables(0);
     end_step('final_configuration');
 case 'final_configuration':
     //
     // Update forum last post information
     //
     $sql = "SELECT forum_id, forum_name \n\t\t\t\tFROM " . FORUMS_TABLE;
     $f_result = query($sql, "Couldn't obtain forum_ids");
     while ($forum_row = $db->sql_fetchrow($f_result)) {
         print " * Updating '" . $forum_row['forum_name'] . "' post info :: ";
         flush();
         $id = $forum_row['forum_id'];
         $sql = "SELECT MIN(p.post_id) AS first_post, MAX(p.post_id) AS last_post\n\t\t\t\t\tFROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t\n\t\t\t\t\tWHERE p.forum_id = {$id}\n\t\t\t\t\t\tAND p.topic_id = t.topic_id";
         $result = query($sql, "Could not get post ID forum post information :: {$id}");
         if ($row = $db->sql_fetchrow($result)) {
             $first_post = $row['first_post'] ? $row['first_post'] : 0;
コード例 #2
0
ファイル: match.php プロジェクト: laiello/bz-owl
function delete_match($match_id)
{
    global $site;
    global $connection;
    global $tables_locked;
    global $viewerid;
    lock_tables();
    // who entered/edited the match before?
    $userid = 0;
    // find out the appropriate team id list for the edited match (to modify total/win/draw/loose count)
    $query = 'SELECT `userid`, `timestamp`, `team1_id`, `team2_id`,' . ' `team1_points`, `team2_points`, `team1_new_score`, `team2_new_score`, `duration` FROM `matches`' . ' WHERE `id`=' . sqlSafeStringQuotes($match_id);
    if (!($result = $site->execute_query('matches', $query, $connection))) {
        unlock_tables();
        $site->dieAndEndPage('Could not find out id for team 1 given match id ' . sqlSafeString($match_id) . ' due to a sql problem!');
    }
    while ($row = mysql_fetch_array($result)) {
        $userid = intval($row['userid']);
        $timestamp = $row['timestamp'];
        $team_id1 = intval($row['team1_id']);
        $team_id2 = intval($row['team2_id']);
        $team1_caps = intval($row['team1_points']);
        $team2_caps = intval($row['team2_points']);
        $duration = intval($row['duration']);
    }
    mysql_free_result($result);
    // prepare to update win/draw/loose count
    // create array that keeps track of team score changes
    $team_stats_changes = array();
    // mark the participating teams as potentially having a changed score
    $team_stats_changes[$team_id1] = '';
    $team_stats_changes[$team_id2] = '';
    // save old match into edit history table
    $query = 'INSERT INTO `matches_edit_stats` (`match_id`, `userid`, `timestamp`, `team1_id`,' . ' `team2_id`, `team1_points`, `team2_points`, `duration`) VALUES (' . sqlSafeStringQuotes($match_id) . ', ' . sqlSafeStringQuotes($userid) . ', ' . sqlSafeStringQuotes($timestamp) . ', ' . sqlSafeStringQuotes($team_id1) . ', ' . sqlSafeStringQuotes($team_id2) . ', ' . sqlSafeStringQuotes($team1_caps) . ', ' . sqlSafeStringQuotes($team2_caps) . ', ' . sqlSafeStringQuotes($duration) . ')';
    if (!($result = $site->execute_query('matches_edit_stats', $query, $connection))) {
        unlock_tables();
        $site->dieAndEndPage('The match reported by user #' . sqlSafeString($viewerid) . ' could not be entered due to a sql problem!');
    }
    // we saved the old match in the editing stats thus we can now delete the actual match
    // update match table (perform the actual editing)
    // use current row id to access the entry
    // only one row needs to be updated
    $query = 'DELETE FROM `matches` WHERE `id`=' . sqlSafeStringQuotes($match_id) . ' LIMIT 1';
    if (!($result = $site->execute_query('matches', $query, $connection))) {
        unlock_tables();
        $site->dieAndEndPage('The match reported by user #' . sqlSafeString($viewerid) . ' could not be deleted due to a sql problem!');
    }
    // update win/draw/loose count
    require_once 'team_match_count.php';
    // both teams didn't play
    decrease_total_match_count($team_id1);
    decrease_total_match_count($team_id2);
    // team 1 won
    if ($team1_caps > $team2_caps) {
        // update team 1 data
        decrease_won_match_count($team_id1);
        // update team 2 data
        decrease_lost_match_count($team_id2);
    }
    // team 2 won
    if ($team1_caps < $team2_caps) {
        // update team 1 data
        decrease_lost_match_count($team_id1);
        // update team 2 data
        decrease_won_match_count($team_id2);
    }
    // the match ended in a draw
    if ($team1_caps === $team2_caps) {
        // update team 1 data
        decrease_draw_match_count($team_id1);
        // update team 2 data
        decrease_draw_match_count($team_id2);
    }
    // old match data variables no longer needed
    unset($userid_old);
    // trigger score updates for newer matches
    update_later_matches($team_id1, $team_id2, $team1_caps, $team2_caps, $timestamp, $team_stats_changes, $viewerid, $duration);
    show_score_changes($team_stats_changes, array_keys($team_stats_changes));
    // done with deleting that match
    unlock_tables();
    require_once '../CMS/maintenance/index.php';
    echo '<p>The match was deleted successfully.</p>' . "\n";
    $site->dieAndEndPage();
}