Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: <?php calls in indexu headers

  1. #1
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default <?php calls in indexu headers

    Im having a problem calling <?php within the header, indexu seems to ignore this.

    I have added the bellow code to the very top of my header.html

    <?php
    $curdir = getcwd ();
    chdir('/home/mysite/public_html/forums');
    require_once('/home/mysite/public_html/forums/global.php');
    chdir ($curdir);
    ?>
    This is a mod for "Vbulletin external login", I thought i would create a test page on its own to elliminate the mod as a problem following bellow

    <?php
    $curdir = getcwd ();
    chdir('/home/mysite/public_html/forums');
    require_once('/home/mysite/public_html/forums/global.php');
    chdir ($curdir);
    ?>
    <html>
    <body>
    This is a heading<br />
    This is some more stuff <br />
    And another line<br />
    You get the idea<br />
    Just place stuff as you normally would with HTML<br />
    I use CSS to style and position on my site fwiw<br />
    <br />
    How about we put the login box right under here?<br />
    <br />
    <?php
    require_once('/home/mysite/public_html/forums/login_inc.php');
    ?>
    </body>
    </html>
    This worked fine, the paths are correct, so i assume theres a method for running <?php within indexu templates??

    I also cleared my cache directorys

    ok

    thanks

  2. #2
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Have you tried using

    <%php%>
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  3. #3
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    IndexU uses smarty, so to use PHP you must use <%php%> and <%/php%>

  4. #4
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    yep this worked thanks

    unfortunatly the php conflicts with indexu and im now stuck, wondered if someone could help.

    The php script is a Vbulletin external login script found here http://www.vbulletin.org/forum/showthread.php?t=108026

    this works fine if a create a test.php file and run from a browser, this works fine even when browsed from the indexu root.
    So paths are correct

    But if i create a block in indexu and call the script i get the following error

    Fatal error: Call to a member function query_first_slave() on a non-object in /home/essext/public_html/forums/includes/functions.php on line 1303
    the line in fuction.php

    PHP Code:
    $user $vbulletin->db->query_first_slave(
    So why would this work in a test.php file but fail in indexu?

  5. #5
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    I'm assuming the code is the same in block is the same as what you put in test.php??? I know that sounds stupid, but just making sure you doubled check.

    The error isn't being generated from within IndexU. Its referencing your vB files. Is it possible your missing some kind of 'include' statement so that it can do a query???
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  6. #6
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    yep exactley the same code for test.php as the block.

  7. #7
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Is it possible to post the code in the block and also how you are calling it? Do you have an HTML and PHP file for the block?
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  8. #8
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    ok for this script to wor on every page i put the following in the header

    <%php%>
    $curdir = getcwd ();
    chdir('/home/essext/public_html/forums');
    require_once('/home/essext/public_html/forums/global.php');
    chdir ($curdir)
    <%/php%>
    this code sets the path and calls vbulletins varibles from global.php.
    all paths correct,


    This is the block code
    <%php%>
    require_once('/home/essext/public_html/forums/login_inc.php');
    <%/php%>
    Calls an external file which is the mod login_inc.php

    here is the mod

    <?php
    // Version 1.10
    // Released April 24th, 2007
    // Edit the line below to show path to your forums
    $forumpath = "http://www.mydomain.co.uk/forums/";


    // You dont have to edit anything underneath here,
    // but you can if you wish to style the login box
    // to match the style of your site.

    // ---------------
    // COPYRIGHT STUFF
    // ---------------
    // You are free to use and modify this script in anyway you like.
    // However,
    // - Do not remove copyright notice
    // - Dont pass it off as your own work.
    //
    // This script is provided free of charges, however If you use this on a commercial
    // venture a small paypal donation to cwp@cwp.id.au would be apprecieated.


    // We check if user is logged in
    if ($vbulletin->userinfo['userid']!=0) {

    // If Logged in display welcome back message
    echo "Welcome Back, <b>";
    echo $vbulletin->userinfo['username'];
    echo " !</b><br />";

    // If logged in display logout link
    echo "<a href=\"".$forumpath."login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
    echo $vbulletin->userinfo['logouthash'];
    echo "\">";
    echo "<font size=\"1\" face=\"verdana\">Log Out</font></a>
    ";

    } else { // If user is not logged in, we do this stuff

    // Display text and link to register.
    echo "
    You have to <a href=\"".$forumpath."register.php?s=$session[sessionhash]\"
    target=\"_parent\"><b>register</b></a> before you can post on our forums or use our advanced features.
    ";

    // Display login boxes + button
    // You can style this with html or CSS as normal if desired.
    echo"
    <form action=\"".$forumpath."login.php\" method=post onsubmit=md5hash(vb_login_password,vb_login_md5pas sword,vb_login_md5password_utf)>
    <script type=text/javascript src=\"".$forumpath."clientscript/vbulletin_md5.js\"></script>
    User Name:<br />
    <input name=vb_login_username type=text id=navbar_username onfocus=\"if (this.value == '$vbphrase[username]') this.value = '';\" size=10 />

    <br />Password:<br />
    <input name=vb_login_password type=password size=10 />
    </br>

    <label for=cb_cookieuser_navbar><input name=cookieuser type=checkbox id=cb_cookieuser_navbar value=1 checked=checked />
    Remember Me?<br /></label>


    <input type=submit title=$vbphrase[enter_username_to_login_or_register] value=\"Log In\" />

    <input type=hidden name=s value=$session[sessionhash] />
    <input type=hidden name=do value=login />
    <input type=hidden name=vb_login_md5password />
    <input type=hidden name=vb_login_md5password_utf />

    </form>
    ";

    }
    ?>

  9. #9
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Echo....

    Do you have a password protecting the entire site? If so, have you tried removing it while testing???
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  10. #10
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    Forcing a login before users can see certain parts is a good thing to do. I do it on external pages on my forum and on indexusupport.

    This can be a good way to fake out authentication and not require logins for IndexU.

    However spammers could still sign up and post crap.

  11. #11
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Agreed.... I just remember when I was setting up my first IndexU site, I password protected the entire site while it was under construction. I was running into a bunch of issues and couldn't figure out what the problem was. As soon as I removed the entire site from being password protected, everything started working correctly
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  12. #12
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    yep i have the root folder indexu live's in password protected, removed the protection but it still reports the same error.

    I think its a conflict of varibles between indexu and vbulletin.

    the error reports line 1303 of functions.php which is

    $user = $vbulletin->db->query_first_slave("
    would the $user be the same in indexu

    cluching at straws again,

  13. #13
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    IndexU uses $username, vbulletin uses $user

  14. #14
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    thanks, have you tried using this mod with indexu ?

  15. #15
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    No I haven't

Similar Threads

  1. Creating Plugins Tutorial and Template calls and varibles
    By echo@ in forum INDEXU DELUXE v1.x
    Replies: 14
    Last Post: 06-02-2008, 10:00 AM
  2. Replies: 2
    Last Post: 03-27-2006, 10:46 AM
  3. Headers Already Sent (Can't fix)
    By andmunn in forum v5.x
    Replies: 6
    Last Post: 03-23-2005, 09:24 PM
  4. PHP Integration - Php Headers
    By brickholius in forum Pre-Sales Questions
    Replies: 2
    Last Post: 10-19-2004, 03:00 PM
  5. headers already sent by....
    By affiliateguide in forum v5.x
    Replies: 0
    Last Post: 07-13-2004, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •