예제 #1
0
 /**
  * Cycle through the url list to call the removeIntroImages function
  */
 private static function removeIntroImagesUrls(&$urls, $px, $text)
 {
     $dbr = wfGetDB(DB_SLAVE);
     foreach ($urls as &$url) {
         $err = '';
         $final_step = '';
         if (!$url['title']) {
             $err = 'Unable to load article';
         } else {
             $introText = '';
             $wikitext = Wikitext::getWikitext($dbr, $url['title']);
             if ($wikitext) {
                 $introText = Wikitext::getIntro($wikitext);
             }
             if (!$introText) {
                 $err = 'Unable to load wikitext';
             } else {
                 //first, let's use the intro image for the final step
                 if ($px > 0) {
                     $new_final_step = self::makeFinalStep($introText, $px, $text);
                     if ($new_final_step) {
                         list($stepsText, $sectionID) = Wikitext::getStepsSection($wikitext, true);
                         $stepsText = $stepsText . $new_final_step;
                         $wikitext = Wikitext::replaceStepsSection($wikitext, $sectionID, $stepsText, true);
                         if (preg_match("@[\r\n]+===[^=]*===@m", $stepsText)) {
                             $final_step = 'x (alt)';
                             //success! (yay!) but has alt methods (boo!)
                         } else {
                             $final_step = 'x';
                             //success!
                         }
                     }
                 }
                 $prevIntroText = $introText;
                 $introText = self::removeIntroImages($prevIntroText, $url['title']);
                 if ($introText && $introText != $prevIntroText) {
                     $wikitext = Wikitext::replaceIntro($wikitext, $introText, true);
                     $comment = 'Removing intro images';
                     if ($final_step == 'x') {
                         $comment .= '; Made final step out of former intro image';
                     }
                     $err = Wikitext::saveWikitext($url['title'], $wikitext, $comment);
                     if (empty($err)) {
                         //make sure the intro image adder doesn't grab it
                         $id = $url['title']->getArticleID();
                         if ($id) {
                             $dbw = wfGetDB(DB_MASTER);
                             $dbw->update('imageadder', array('imageadder_hasimage' => 1), array('imageadder_page' => $id));
                         }
                     }
                 } else {
                     $err = 'Either no intro image or no intro found';
                 }
             }
         }
         $url['err'] = $err;
         $url['final_step'] = $final_step;
     }
 }
예제 #2
0
<?php

require_once 'commandLine.inc';
$dbw = wfGetDB(DB_MASTER);
print "Getting articles...\n";
$wgUser = User::newFromName('MiscBot');
$title_array = array('Make-a-LEGO-Key-Holder', 'Use-DigiArty-WinX-DVD-Author', 'Make-a-Shanghai-Cocktail', 'Switch-Tabs-in-Chrome', 'Catch-Walleye', 'Detect-Nofollow-Links', 'Make-a-Line-Plot', 'Make-the-Drink-the-Brain', 'Calculate-Stocking-Rates-for-Your-Pastures', 'Plead-Against-a-Ban-on-RuneScape', 'Make-Idli-Gunpowder-(Molagapodi)', 'Treat-Costochondritis', 'Enjoy-Calculus', 'Remove-Pips-from-Grapes', 'Alleviate-a-Sore-Nose-With-Petroleum-Jelly', 'Crochet-Shawls', 'Clean-and-Disinfect-Ice-Trays', 'Record-an-Upright-Acoustic-Bass', 'Make-a-Survival-Kit-in-a-Bottle', 'Carry-a-Football', 'Fix-a-Leaking-Roof', 'Write-a-Robots.Txt-File', 'Cope-With-Disruptive-People-During-a-Movie', 'Have-a-Private-Conversation-in-Public', 'Celebrate-National-Poetry-Month', 'Have-Fun-With-People-That-You-Don%27t-Like', 'Make-Premium-Pizzeria-Pizza', 'Create-a-Feeding-Routine-for-Your-Dog', 'Make-Hydrogen-from-Muriatic-Acid', 'Integrate-Music-Into-Creative-Writing', 'Be-an-Awesome-Girl-Without-Being-Athletic', 'Do-a-Buoyancy-Check', 'Make-Dryer-Sheets', 'Recite-the-Spanish-Alphabet', 'Use-Magnets-to-Locate-Studs', 'Do-Drive-By-Editing-While-Patrolling-wikiHow', 'Avoid-Awkward-Silences-when-You-Meet-Someone-Again-After-Sleeping-With-Them', 'Copy-an-Encrypted-DVD-to-a-Smaller-Capacity', 'Organize-Cloth-Diapers', 'Love-Your-Child-(Indian-Culture)', 'Cook-Fish-in-a-Double-Boiler', 'Get-Someone-to-Let-You-Draw-Them-Naked', 'Tie-a-Snapping-Turtle-So-It-Won%27t-Bite-You', 'Record-a-Kick-Drum', 'Reject-a-Homecoming-Date-(Girls)', 'Diagnose-High-Thyroid-Levels-in-a-Cat', 'Plan-a-Date-for-a-Foodie', 'Brew-Amber-Beer', 'Choose-an-Online-Dog-Training-Course', 'Make-Pickles-from-Leftover-Brine', 'Eradicate-the-Fear-of-Stuttering', 'Create-Nintendo-Wii-Skins', 'Convince-Your-Parents-to-Celebrate-4th-of-July', 'Improve-Your-Swim-School-Business', 'Unlock-the-Death-Count-in-Super-Mario-Galaxy', 'Buy-a-Waterproof-Camera', 'Make-Mock-Chicken-Filling', 'Make-Yogurt-Berry-Muffins', 'Make-a-Sphagnum-Moss-Wreath', 'Resist-the-Firemen%27s-Carry', 'Change-Instruments-from-Bb-Clarinet-to-Soprano-Saxophone', 'Get-the-Best-from-Fine-Scotch-Whiskies', 'Avoid-Unscrupulous-Bad-Credit-Loan-Brokers', 'Take-Care-of-a-Deaf-Great-Dane', 'Have-a-Gay-Marriage-in-New-York-Even-if-the-Church-Says-No', 'Protest-TSA-Screening-As-Sexual-Assault', 'Keep-Germs-off-Your-Purse', 'Teach-Your-Kids-to-Enjoy-Classic-Books', 'Appreciate-Patrick-Swayze', 'Cut-Down-on-Your-Medical-Costs', 'Change-the-Feel-of-a-Scene', 'Market-Your-Music-Like-Sir-Alan-Sugar', 'Make-Watercress-Potato-Salad', 'Be-a-Word-Collector', 'Get-the-IP-Address-of-Any-Website', 'Read-Supermarket-Labels', 'Make-Teriyaki-Grilled-Corn', 'Visit-the-Westminster-Clock-Tower', 'Build-a-Childrens-Ministry', 'Go-Green-at-the-Trade-Show', 'Pick-a-Mezuzah-Case', 'Get-a-Steady-Violin-Bow', 'Take-Your-Dog-for-a-Walk-in-Winter', 'Make-Wheat,-Beet-and-Walnut-Salad', 'Edit-wikiHow-Using-an-iPod-Touch', 'Make-Orange-(the-Fruit)-Jelly-Pumpkins', 'Leave-Home-for-the-First-Time', 'Hold-a-Cello-when-Resting', 'Destroy-a-Fortified-Position-in-Nerf', 'Get-a-Friend-to-Stop-Playing-the-Race-Card', 'Follow-Recent-Earthquakes-in-New-Zealand', 'Get-over-Your-Fear-of-Banks', 'Enjoy-the-Process-of-Drawing-Despite-Any-Messups', 'Get-to-Glasgow', 'Persuade-a-Friend-to-Let-You-Borrow-Her-Clothes', 'Look-Like-a-Tennis-Player', 'Make-Orange-and-Mustard-Chicken-Drummers', 'Wear-Boyfriend-Jeans', 'Vote-for-American-Idol', 'Use-the-Internet', 'Use-a-Proxy', 'Get-Good-at-Quick-Scoping-and-No-Scoping-on-Call-of-Duty-Black-Ops', 'Prune-Clematis', 'Play-Dota-2', 'Make-Hot-Fudge', 'Make-French-Onion-Soup', 'Make-a-Drum', 'Live', 'Have-Fun-With-Friends', 'Fly-in-Pandaria', 'Evolve-Clamperl-in-Pokemon', 'Come-out-of-One%27s-Shell', 'Catch-a-Pokemon-(Advanced)', 'Breed-the-Rainbow-Dragon-on-DragonVale', 'Update-Minecraft-for-the-Xbox-360-Version', 'Force-a-Burp', 'Immigrate-Into-the-United-States-Permanently', 'Install-Google-Talk-on-Your-Computer', 'Make-YouTube-Stop-Buffering', 'Burn-an-ISO-File-on-Windows-7', 'Do-the-%22Gallon-of-Milk%22-Challenge', 'Get-Unlimited-Money-on-the-Sims-3-for-PC', 'Camp-in-Call-of-Duty-Ghosts', 'Get-Hats-in-Team-Fortress-2', 'Start-a-Writer%27s-Notebook', 'Install-Windows-8-from-USB', 'Know-if-Your-Fish-Is-Male-or-Female', 'Use-a-Computer-Printer', 'Cook-Green-Split-Peas', 'Cook-Steak-in-the-Oven-So-It%27s-Tender', 'Adopt-a-Kid-in-the-Sims-3', 'Put-a-SIM-Card-Into-an-iPhone-3GS', 'Trim-a-String-in-Java', 'Make-Lavender-Tea', 'Change-Your-Name-in-Massachusetts', 'Make-a-Coffee-Milkshake', 'Make-Your-Own-Emergency-Eyeliner', 'Fix-Yu-Gi-Oh-Power-of-Chaos%27s-Data-Saving-Problem', 'Export-Audio-in-Audacity', 'Grow-Breasts-Without-Surgery', 'Use-Nasturtiums-in-Food', 'Catch-Bagon-on-Pokemon-Ruby', 'Use-Yahoo!-Answers', 'Transfer-Contacts-from-Windows-Mobile-Phone-to-Pc-with-GodswMobile.Com', 'Remove-an-Application-Off-Your-Twitter-Account', 'Edit-a-Facebook-Business-Page', 'Delete-Something-from-the-History-Section-of-Favourites', 'Make-a-Microphone-from-a-Speaker', 'Get-Rid-of-a-Beer-Belly', 'Live-a-Holistic-Life-of-Personal-Development', 'Get-Pichu-in-Pokemon-Ruby', 'Get-to-the-North-Pole', 'Delete-Your-iTunes-Library-(Mac)', 'Change-Your-Name-in-Kentucky', 'Get-a-Riolu-Egg-in-Pokemon-Diamond', 'Rent-a-Private-Mailbox', 'Incorporate-in-New-York', 'Text-a-Girl-(Young-Teens)', 'Fix-Usb-Device-Not-Recognized-Error', 'Find-the-Best-Muscle-Building-Workout', 'Access-a-Web-Page-That-Doesn%27t-Load-Fully', 'Be-Friends-With-Everyone-in-Sims-2', 'Hold-a-Guitar', 'Disable-a-Stolen-Mobile-Phone', 'Grow-Bird%27s-Nest-Fern-As-an-Indoor-Plant', 'Travel-with-Your-Guitar', 'Be-Familiar-with-the-Falcon-Crest-TV-Series', 'Use-E-Liquid', 'Draw-a-Sad-Face', 'Evolve-Electabuzz', 'Dump-Your-Boyfriend-in-Middle-School', 'Look-Goth-While-Traveling-for-a-Long-Time-on-a-Plane', 'Jailbreak-Your-iDevice-Right-from-It', 'Call-and-Text-With-Google-Voice-on-an-iPod-Touch', 'Build-a-Snail-House', 'Create-a-Website-With-Weebly.Com', 'K-Style-in-Gunz', 'Be-Bad', 'Be-Optimistic-in-a-Pessimistic-World', 'Become-a-Playback-Singer-in-Mumbai', 'Set-up-FTP-in-cPanel', 'Bypass-Impero-Blocking', 'Choose-Shaolin-Kung-Fu-Style', 'Use-an-Overhead-Projector', 'Make-Hair-Gel-Using-Aloe-Vera-Pulp', 'Have-Fresh-Breath', 'Make-a-Quick-Comic-Book', 'Make-a-Roblox-Username', 'Remove-DRM-from-Amazon-Video-on-Demand', 'Sound-Exactly-Like-Green-Day-for-Under-$500', 'Qualify-for-Innocent-Spouse-Tax-Relief', 'Dye-Your-Hair-with-a-Sharpie-Marker', 'Find-the-Big-Dipper', 'Create-the-Ultimate-Stamina-Type-Metal-Fight-Beyblade', 'Make-Windows-7-Calculator-Crash', 'Perform-a-Math-Trick', 'Use-Retinol', 'Get-Console-on-Counter-Strike-Source', 'Close-Your-Golf-Stance', 'Remove-a-Door-Panel-on-a-Chevy-Tracker', 'Apply-Individual-Eyelashes', 'Practise-Your-Weaker-Foot-for-Soccer', 'Obtain-a-Kentucky-Concealed-Deadly-Weapons-License', 'Get-a-Boyfriend-on-Animal-Jam', 'Practice-Drum-Rolls', 'Change-Your-Modern-Warfare-2-Name-Color', 'Play-Blindfolded-Makeover', 'Make-Easy-No-Bake-Cheesecake', 'Check-Your-Webpage-Loading-Time-with-Google-Analytics', 'Give-Your-Dog-a-Massage', 'Avoid-Awkward-Conversations', 'Check-Linux-Distribution', 'Host-a-Shower-for-a-Second-Wedding', 'Return-to-Sender', 'Deal-With-Parents', 'Fix-Slippery-Basketball-Shoes', 'Use-an-MLS', 'Check-Your-PSP-Firmware', 'Apply-for-a-Marriage-License-in-Nevada', 'Turn-Safely-on-a-Motorcycle', 'Look-Great-for-Swimming', 'Make-Nickelodeon-Slime', 'Set-up-a-Laptop-Computer-Station', 'Write-Declarative-Sentences', 'Open-the-Shed-on-Virtual-Families', 'Change-Pink-Paint-Into-an-Orange-Color', 'Sync-Files-Between-Computers-Using-Dropbox', 'Measure-a-Box', 'Do-a-Cartwheel-in-Gymnastics', 'Save-Text-Messages-on-a-Cell-Phone', 'Remove-Screws-That-Have-Been-Painted-Over', 'Commit-to-a-Relationship', 'Hit-the-Smash-Shot-in-Table-Tennis', 'Roleplay-a-Warrior-Cat-Online', 'Do-General-Maintenance-on-Airsoft-Gas-Blowback-Pistols', 'Write-a-Cheesy-Song', 'Make-a-Collage-Poster', 'Operate-a-CB-Radio', 'Do-a-Frontflip-With-a-Full-Twist-in-Gymnastics', 'Get-a-Soccer-Coaching-License', 'Act-Like-a-Hunter-from-Left-4-Dead', 'Draw-Insects', 'Win-a-Zynga-Poker-Sit-and-Go-Tournament', 'Handle-Being-Stuck-in-the-Middle-of-a-Fight', 'Become-an-Accountant-in-Florida', 'Do-a-Side-Effect', 'Get-Cat-Hairs-off-Your-Tongue', 'Tell-if-It-Is-Raining', 'Make-Your-Glasses-White-by-Reflection', 'Get-Ink-Flowing-in-Gel-Pens', 'Apply-for-a-Citibank-Credit-Card', 'Take-an-Online-Defensive-Driving-Course-for-Ticket-Dismissal-in-Florida', 'Set-a-GPS-with-a-Location', 'Deal-With-a-Guy-Who-Has-Used-You', 'Care-for-an-Ant', 'Tell-a-Girl-She-Has-Nice-Feet', 'Talk-Like-Stitch', 'Stop-a-Horse-from-Chewing-Wood', 'Make-Canadian-Style-Steak-Seasoning', 'Use-Nearbytweets.Com-to-Find-Tweeters-Near-You', 'Get-the-Rarest-Fish-on-Fish-Tycoon', 'Set-a-Noise-Gate-for-Vocals', 'Comment-in-HTML', 'Stop-Corruption-in-Your-Work-Place', 'Learn-Welsh', 'Decorate-a-Square-Living-Room', 'Defeat-Silver-the-Hedgehog-in-Sonic-the-Hedgehog-Next-Gen', 'Design-a-Simple-Web-Page-in-Div', 'Get-the-Best-Deal-when-Trading-Games-in-at-Gamestop', 'Ride-an-Electric-Scooter', 'Convince-Your-Parents-to-Get-You-a-Double-Bed', 'Perform-a-Shining-Wizard-Combo-Move-in-Pro-Wrestling', 'Thicken-Fake-Blood', 'Recover-Lost-Filezilla-FTP-Client-Passwords', 'Have-to-Pack-Your-Bag-for-Cheerleading', 'Make-a-Fart-Noise-With-a-Straw', 'Save-All-Your-Pocket-Money-Without-Spending-It', 'Act-Like-Spongebob-Squarepants', 'Build-a-Computer-Using-Tangible-Acoustic-Interfaces', 'Attract-Latin-Guys', 'Sleep-With-Your-Best-Friend-Nude', 'Cure-Hiccups-With-the-Sugar-Method', 'Prove-that-you-are-an-Eminem-Fan', 'Skip-and-Criss-Cross', 'Create-a-Template-for-Your-ID-Cards', 'Get-Tested-for-Chlamydia', 'Be-an-Easygoing-Parent', 'Be-Friends-With-Someone-Who-Shares-Your-First-Name', 'Do-a-Right-Leap', 'Create-a-Facebook-Account-Behind-Your-Parents-Back', 'Set-up-a-Spy-or-CSI-Agency', 'Activate-a-Blackberry-on-BES', 'Prevent-a-Dog-and-Cat-Tapeworm-Infection-(Dipylidium-Infection)', 'Not-Kick-in-Bed', 'Celebrate-Beltane', 'Cope-with-a-Staff-Shortage', 'Avoid-a-Guy-at-School', 'Draw-a-Lego-Spiderman', 'Build-Muscle-for-Weightlifting', 'Develop-a-Southern-Accent', 'Snowshoe', 'Make-a-Lean-To-Shelter', 'Make-Mini-Fruit-Pizzas-on-Sugar-Cookies', 'Recognize-a-Handball-in-Soccer', 'Find-Insurance-Records-from-a-Previous-Owner-of-a-Car', 'Use-Lowe%27s-Coupons', 'Come-up-With-a-Great-Quiz-Idea', 'Have-a-Beyonce-Makeup-Look', 'Pitch-Submarine', 'Make-a-Diaper-for-a-Male-Dog', 'Avoid-Keeping-Hair-Dye-in-Too-Long', 'Guess-Someone%27s-Age-Correctly', 'Convince-Your-Parents-to-Let-You-Buy-a-Mouse', 'Play-Fade-to-Black', 'Get-a-Homeschooled-Girl-to-Like-You', 'Buy-a-Video-Capture-Card', 'Be-an-Anti-Emo-Christian', 'Fix-a-Hanging-GM-Headliner', 'Break-up-With-Someone-Without-Hurting-Their-Feelings', 'Find-Someone-Else%27s-Marriage-License', 'Measure-Ski-Poles', 'Become-a-Real-Life-Tekken-Fighter', 'Improve-Your-Beer-Bong%27s-Effectiveness', 'Write-a-Romantic-Poem-at-the-Top-of-Your-Head', 'Thank-Someone-for-Coming-to-Your-Graduation-Party', 'Execute-a-Go-Around-in-a-Cessna-172', 'Order-a-Free-Watchtower-Bible', 'Decorate-a-Tween-Girl%27s-Room', 'Make-Your-Clothes-Emo-or-Goth', 'Act-Like-an-Addams-from-the-Addams-Family', 'Know-How-Often-to-Instant-Message-Someone-Without-Being-Clingy', 'Speak-With-a-Hindu-Accent', 'Watch-Football-on-Android', 'Make-a-Kissgloss-Lip-Scrub', 'Catch-Sardines-in-RuneScape', 'Invest-in-a-Store-in-Oblivion', 'Draw-a-Kiwi', 'Put-Together-a-Goodie-Bag', 'Deal-With-a-Crush-on-a-Relative', 'Play-with-Earthshaker-in-Defense-of-the-Ancients-(DotA)', 'Remove-Strawberry-Stains', 'Play-Smash-Well', 'Buy-a-50th-Wedding-Anniversary-Gift', 'Take-a-Bath-Without-Getting-Your-Hair-Wet', 'Complete-All-Poptropica-Islands-Quickly', 'Make-Aromatic-Blend-Bath-Salts', 'Find-Out-Your-GMAT-Results', 'Remove-Wax-from-Concrete', 'Highlight-the-Mouth-With-Makeup', 'Do-an-Impression', 'Be-a-Girly-Tomboy-in-Fifth-Grade', 'Do-the-Moonwalk-Forwards', 'Catch-a-Ditto-in-Pokemon-Diamond', 'Find-the-Best-Online-Dating-Sites', 'Recover-from-a-Bad-Round-of-Golf', 'Make-Money-by-Selling-Shirts-Online-for-Free', 'Find-Video-Game-Cheats-Online', 'Cut-Holes-in-a-T-Shirt', 'Buy-a-Personal-Jet', 'Place-the-Cake-at-Your-Wedding-Reception', 'Eat-Gross-Food', 'Communicate-With-Your-Spouse', 'Get-Plenty-of-Sleep-Before-a-Test', 'Get-Pid-in-Java', 'Kill-Most-Bosses-in-Resident-Evil-4', 'Hatch-Frog-Eggs', 'Make-a-Justin-Bieber-Poster', 'Be-a-Feminist-Without-Displaying-Your-Victimhood-Complex', 'Create-a-Clan-Cat', 'Not-Start-Drama', 'Buy-a-Shaver', 'Make-a-Barbie-Cooking-Show', 'Use-Spell-Scrolls-in-Ultima-IX-Multiple-Times-Without-Losing-the-Scroll', 'Buy-a-Keg', 'Make-the-Laptop-More-Secure-Operating-System', 'Choose-an-Iron-Supplement', 'Have-a-Fake-Phone-Conversation', 'Spot-a-Manipulator', 'Stop-a-Dog-from-Climbing-up-on-Things', 'Prevent-Your-Computer-from-Restarting-in-the-Middle-of-the-Night', 'Act-As-More-Than-One-Anime-Character-at-Once', 'Calculate-Family-Medical-and-Leave-Act-Leave-Time-Used', 'Evolve-Pichu-Into-Pikachu-on-Pokemon-Diamond', 'Be-the-Perfect-Bride', 'Fix-Avast-Setup-Registry-Errors', 'Make-Money-With-Domain-Parking', 'Kill-Your-Sim-With-Fire-on-the-Sims-2', 'Get-Leafeon-on-Pokemon-Diamond,-Pearl,-or-Platinum', 'Catch-Cod', 'Keep-Calm-on-Exam-Results-Day', 'Add-Moderators-to-a-Chat-Room-on-Justin.Tv', 'Shift-on-a-Quad-With-Clutch');
print "Done. Let us process the " . count($title_array) . " articles.\n";
$count = 0;
foreach ($title_array as $title_name) {
    $title = Title::newFromText($title_name);
    if (!$title) {
        continue;
    }
    $rev = Revision::loadFromTitle($dbw, $title);
    if ($rev) {
        $wikitext = $rev->getText();
        $intro = Wikitext::getIntro($rev->getText());
        if (preg_match("@{{stub[^}]*}}@i", $intro)) {
            $intro = preg_replace("@{{stub[^}]*}}@i", "", $intro);
            $wikitext = Wikitext::replaceIntro($wikitext, $intro, true);
            print "Removing from: " . $title->getText() . "\n";
            $article = new Article($title);
            $article->doEdit($wikitext, "Removing incorrectly placed stub template");
            $count++;
        }
    }
}
print "Deleted from {$count} articles\n";
예제 #3
0
 function categorize($aid)
 {
     global $wgRequest;
     $t = Title::newFromId($aid);
     if ($t && $t->exists()) {
         $dbr = wfGetDB(DB_MASTER);
         $wikitext = Wikitext::getWikitext($dbr, $t);
         $intro = Wikitext::getIntro($wikitext);
         $intro = $this->stripCats($intro);
         $cats = array_reverse($wgRequest->getArray('cats', array()));
         $intro .= $this->getCatsWikiText($cats);
         $wikitext = Wikitext::replaceIntro($wikitext, $intro);
         $result = Wikitext::saveWikitext($t, $wikitext, 'categorization');
         // Article saved successfully
         if ($result === '') {
             wfRunHooks("CategoryHelperSuccess", array());
         }
     }
 }