Fork me on GitHub

Get module type  Bottom

  • Im working on a hack that i might be turning into a plugin that will load a particular peice of code. It all depends on if "user" or "admin" areas are being viewed. For some reason i cant seem to be able to pull that variable information out of URL. Currently im just trying some simple PHP Smarty code in a template to see if can get it working, then from there i turn it into a pnrender plugin hopefully. Anyway, its 6am for me and i have been up all night, so im probably missing something simple.

    Most of the code here is just for testing, but here is what i have:

    Code

    <!--[php]-->

    $filename = $_SERVER['PHP_SELF'];
    $newfilename = str_replace("/", "", $filename);

    //print_r $filename;

    if ($type == 'admin' || $module == 'advProfile' || $module == 'User' || $newfilename == 'user.php'){

    $domain = $_SERVER['HTTP_HOST'];
    $newdomain = str_replace("secure.", "", $domain);

        if ( isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'on' ) {
           header ('Location: http://'.$newstring.$_SERVER['REQUEST_URI']);
           exit();
        }
    }

    echo $newfilename;
    <!--[/php]-->
  • You are assuming the variable $type is available, which it might not be, so shouldn't you be pnVarCleanFromInput() them first?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • $type is available only with register_globals = on which is a bad idea for security. pnVarCleanFromInput, as Simon mentioned, is the correct way.

    --
    "He is not dangerous, he just wants to play...."
  • yep, got it working. Thanks!

    Now i have SSL for logins, edit user, and all administration. Woo hoo!
  • Great work!

    Care to write a tutorial for the masses?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Unfortunately my solution is just a hack for Xanthia themes only. If someone wants to work with me to clean it up and turn it into a real solution, i would be glad to share it.
  • If you share the hack we can see how it can be implemented correctly (this does not mean that your solution is not correct!)

    Feel free to post it to the patch tracker on NOC.

    --
    "He is not dangerous, he just wants to play...."

This list is based on users active over the last 60 minutes.