• If you want to password protect a category in 1.22 Kubrick, do the following:

    1. In index.php above everything else add:

    <?
    session_start();

    if (!session_is_registered("password"))
    {
    $cart=array();
    session_register("password");
    }

    if ($_POST["txtPassword"]) $password=$_POST["txtPassword"];
    $secretpassword = "yoursecretpassword";
    ?>

    2. In the above code, change yoursecretpassword to your desired password.

    3. In index.php (in the Begin Archives area), between:

    <div id="content" class="narrowcolumn">

    <?php if ($posts) { ?>

    add:

    <?php
    if (($_GET["cat"] == 2 || $_GET["cat"] == 6 || $_GET["category_name"] == "passwordedcat2" || $_GET["category_name"] == "passwordedcat6") && ($password != $secretpassword))
    {
    //This is where the login form goes
    echo "
    <form name="form" method="post" action="";
    echo $_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];
    echo "">

    <b>Password:</b>
    <input type="password" title="Enter your password" name="txtPassword" />

    <input type="submit" name="Submit" value="Login" />

    </form>
    ";
    }
    else
    {?>

    4. You might want to change passwordedcatx to your category name.

    Maybe someone can make a plugin of this if there isn’t one yet. You might want to combine this with Kitten’s Show Categories plugin to prevent passworded categories from showing up on the main page.

    YoB

Viewing 2 replies - 1 through 2 (of 2 total)
  • I hope someone makes this to a hack, that would be great.
    I just get a buch of errors when I try this code

    parse error, unexpected T_STRING, expecting ‘,’ or ‘;’

    Thread Starter Labradork

    (@yardobeef)

    A T_STRING error: I think that means that the code has mismatched quotation marks somewhere. Perhaps a comma or semicolon is in the wrong place too. Maybe someone with a better eye than me can spot the culprit.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Password protecting your categories’ is closed to new replies.