• “Just being a mediocre driver has never been my ambition. That's not my style” ― Michael Schumacher
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Have a chance to win a copy of F1 2017 The Game (PC) by following RaceDepartment on Twitter, Facebook, Instagram, Twitch, Steam and / or YouTube.

Fix for the 'screwed up' posts in F1 2011 Setup Forums

Discussion in 'Site Feedback & Support' started by Benjamin Boerngen-Schmidt, Nov 25, 2011.

  1. Benjamin Boerngen-Schmidt

    Benjamin Boerngen-Schmidt

    Messages:
    25
    Ratings:
    +10
    Hi there,

    it really annoys me, that the Posts in the Setup Forum ain't readable any more, so I coded a litte php script which does clean them up.

    PHP:
    <?php
     
    // Connect to the Database
    //$pdo = new PDO('mysql:host=127.0.0.1;dbname=forum', 'username','password');
    // Select all post form the Racesetup Forum
    //$sql = "SELECT ....";
     
    // Sample post
    $post = <<<EOF
    [TABLE="class: grid"]
    [TR]
    [TD]Car
    [/TD]
    [TD]WILLIAMS
    [/TD]
    [/TR]
    [TR]
    [TD]Circuit
    [/TD]
    [TD]NURBURGRING
    [/TD]
    [/TR]
    [TR]
    [TD]Condition
    [/TD]
    [TD]WET
    [/TD]
    [/TR]
    [TR]
    [TD]Distance
    [/TD]
    [TD]20%
    [/TD]
    [/TR]
    [TR]
    [TD]Aerodynamics
    [/TD]
    [TD]Front Wing Angle: 9
    Rear Wing Angle:11
    [/TD]
    [/TR]
    [TR]
    [TD]Braking
    [/TD]
    [TD]Balance: F 50% - R 50%
    Pressure: MED
    Brake Size:STND
    [/TD]
    [/TR]
    [TR]
    [TD]Balance
    [/TD]
    [TD]Front Anti-Roll Bar:11
    Rear Anti-Roll Bar:11
    [/TD]
    [/TR]
    [TR]
    [TD]Suspension
    [/TD]
    [TD]Front Ride Height: 3
    Rear Ride Height: 3
    Front Spring Stiffness:11
    Rear Spring Stiffness:11
    [/TD]
    [/TR]
    [TR]
    [TD]Gearbox
    [/TD]
    [TD]Gear 1: xxx kph / 6 left mph
    Gear 2: xxx kph / 5 left mph
    Gear 3: xxx kph / 4 left mph
    Gear 4: xxx kph / 3 left mph
    Gear 5: xxx kph / 2 left mph
    Gear 6: xxx kph / 1 left mph
    Gear 7: xxx kph / 196 mph
    [/TD]
    [/TR]
    [TR]
    [TD]Engine
    [/TD]
    [TD]Fuel Map: -
    Fuel:full
    [/TD]
    [/TR]
    [TR]
    [TD]Alignment
    [/TD]
    [TD]Camber Front:-3.50
    Camber Rear: 1.40
    Toe Front: 0.08
    Toe Rear:0.35
    [/TD]
    [/TR]
    [TR]
    [TD]Tyres
    [/TD]
    [TD]opt
    [/TD]
    [/TR]
    [TR]
    [TD]Notes
    [/TD]
    [TD]1.30.569 in dry 1.36 in wet
    [/TD]
    [/TR]
    [/TABLE]
    EOF;
    $post preg_replace('/\[TABLE="class: grid"\]\s/'''$post);
    $post preg_replace('/\[TR\]\s\[TD\](\w+)\s\[\/TD\]\s\[TD\]/'"[B]\$1[/B]\n"$post);
    $post preg_replace('/\[\/TD\]\s\[\/TR\]/'"\n"$post);
    $post preg_replace('/\[\/TABLE\]\s/'''$post);
     
    print(
    $post);
    ?>
    Hope this helps!
     
    • Like Like x 1
  2. Benjamin Boerngen-Schmidt

    Benjamin Boerngen-Schmidt

    Messages:
    25
    Ratings:
    +10
    Hello Dear Mr. Administrator,

    does this script help you any thing? Will you apply it? May I work into it a little more, with coding the SQL Statement and the Loop?

    Cheers
    - benjamin
     
    • Like Like x 1
  3. Bram Hengeveld

    Bram Hengeveld
    Administrator Staff Premium

    Messages:
    42,812
    Ratings:
    +16,619
    Ouch I thought I replied in this thread to thank you for the suggestion but I guess I forgot. Sorry m8, really rude.

    I have forwarded this post to the SQL guru (who is sleeping now) :)
     
  4. Xosé Estrada

    Xosé Estrada
    Premium

    Messages:
    4,288
    Ratings:
    +817
    I don't have time now after the migration to look into this Benjamin, but if you code the SLQ and the loop I can run it.
     
    • Like Like x 1
  5. Benjamin Boerngen-Schmidt

    Benjamin Boerngen-Schmidt

    Messages:
    25
    Ratings:
    +10
    For the SQL I would need some sample Data, like structure of the posts table, forums table and some actual posts (just mine would be fine). Maybe its best if one of you contacts me via messenger or so.

    - benjamin