Skip to content

Instantly share code, notes, and snippets.

@macek
Created December 7, 2011 23:10

Revisions

  1. Paul Macek created this gist Dec 7, 2011.
    30 changes: 30 additions & 0 deletions hijack.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <pre>
    <?php

    class Loader {
    static public function helper($class){
    echo "including concrete5 {$class}\n";
    }
    }

    class MyLoader {
    static public function helper($class){
    if($class == "captcha"){
    echo "loading my super secret {$class}\n";
    }
    else {
    Patchwork\pass();
    }

    }
    }


    $hijack = Patchwork\replace('Loader::helper', 'MyLoader::helper');

    Loader::helper("captcha");
    Loader::helper("foobar");

    Patchwork\undo($hijack);

    Loader::helper("captcha");