Как переделать код чтобы он соответствовал ООП MVC?

Рейтинг: 0Ответов: 2Опубликовано: 07.04.2015

Данный код надо переделать в ООП MVC:

if (isset($_POST['length'])){


    $length = $_POST['length'];
    for($j=1;$j<=3;$j++){
        if ($_POST['opt' . $j] == 'on') {
            $checked_count+=1;
        }
    }

    if (isset($_POST['opt1']) && $_POST['opt1'] == 'on'){
        $boo = $length - ($checked_count - 1); $checked_count -= 1;
        $baz = rand(1,$boo);
        $num = str_shuffle($num);
        for ($i=0; $i < $baz; $i++) { 
            $pw .= $num[$i];
        }
    }

    if (isset($_POST['opt2']) && $_POST['opt2'] == 'on'){
        $boo = $length - $baz -($checked_count - 1); $checked_count -= 1;
        $baz = rand(1,$boo);
        $upper_alpha = str_shuffle($upper_alpha);
        for ($i=0; $i < $baz; $i++) { 
            $pw .= $upper_alpha[$i];
        }
    }

    if (isset($_POST['opt3']) && $_POST['opt3'] == 'on'){
        $baz = $length - strlen($pw);
        $alpha = str_shuffle($alpha);
        for ($i=0; $i < $baz; $i++) { 
            $pw .= $alpha[$i];
        }
    }
}
?>

<!-- VIEW-->
<form method="POST" action="index.php">
             <h3>Select Characters</h3>


             <input type="checkbox" checked="on" name="opt1"> Numbers without 0 and 1


             <input type="checkbox" checked="on" name="opt2"> Big letters without O and o


             <input type="checkbox" checked="on" name="opt3"> Small letters without "l"


             <h3 style="margin: 20px 0;">Password Length</h3>


             <input type="text" name="length" size="1" maxlength="1">


             <input type="submit" value="Generate">



            <div style="padding: 20px 0;">
                <div>Your Password:</div>
                <div style="width:200px; height:15px; border:1px black solid; font-size: 14px; font-family: monospace; padding:3px; color:#000; background-color: #D2E0E6; margin: 0;"><?php echo str_shuffle($pw) ?></div>
            </div>
</form>

Я даже не знаю с чего начать, ибо если я правильно понял правила MVC, то у меня не правильно так, как method находится в controller'е. Как переделать код чтобы он соответствовал ООП MVC?

Ответы

Ответов пока нет.