Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Posts posted by scottybwoy

  1. Ok I still think there is something wrong with my addresses as now I get Document Moved : Please click here, but here refers to :

    c:/Inetpub/wwwroot/databaseC:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/scripts/login/login.php?url=http://my-server.my.local

    The login.php is actually in /scripts/login/login.php  but I don't understand why it's passing this URL to the browser because it's not a valid address.

    Ok I'm going to post my code for home.php can anybody see where login.php is being called, as I'm a newbie and don't understand it very well.

    [code]
    <?php

      require_once "home.conf.php";

      require_once $INTRANET_USER_CLASS;

      /* Session variables must be defined before session_start() method is called */
     
      class IntranetUserHomeApp extends PHPApplication {

      function run()
          {
             
              if (! $this->authorize($this->getSessionField('SESSION_USERNAME')))
              {
                $this->alert('UNAUTHORIZED_ACCESS');
              }

              $this->uid = $this->getUID();

              // At this point user is authorized
              $this->displayHome();
        }

          function authorize()
          {
              return TRUE;
          }

      /*
          function updateMsgTrack()
          {
            $mid = $this->getRequestField('mid');

            $msgObj = new Message($this->dbi);
            $msgObj->updateTrack($this->uid, $mid);
            return true;
          }
      */

          function displayHome()
          {
              global $HOME_MNGR;
              global $HOME_TEMPLATE;
              global $THEME_TEMPLATE, $INTRANET_DIR;
              global $THEME_TEMPLATE_DIR, $REL_TEMPLATE_DIR;
              global $REL_TEMPLATE_DIR, $INTRANET_DIR;
              global $PHOTO_DIR, $DEFAULT_PHOTO, $REL_PHOTO_DIR;

              $Template = Template($HOME_TEMPLATE_DIR);

              $themeTemplate->set_file('fh', $THEME_TEMPLATE[$this->theme]);
              $themeTemplate->set_block('fh', 'mmainBlock', 'mmblock');
             
              $photoFile = sprintf("%s/photo%003d.jpg",$PHOTO_DIR, $this->getUID());
              $photo = file_exists($photoFile) ? sprintf("%s/photo%003d.jpg",$REL_PHOTO_DIR,$this->getUID()) : sprintf("%s/%s",$REL_PHOTO_DIR,$DEFAULT_PHOTO);
              $themeTemplate->set_var('PHOTO', $photo);

              $themeTemplate->set_var('TEMPLATE_DIR', $REL_TEMPLATE_DIR);

              $themeTemplate->set_var('LEFT_NAVIGATION', $this->themeObj->getLeftNavigation($THEME_TEMPLATE_DIR . '/' . dirname($THEME_TEMPLATE[$this->theme])));

              $template = new Template($this->getTemplateDir());
              $template->set_file('fh1', $HOME_TEMPLATE);
              $template->set_block('fh1', 'mainBlock', 'mblock');
              $template->set_block('mainBlock', 'msgBlock', 'msg');
             
              $template->set_var('msg', null);

              $now = time();

              $template->set_var(array(
                                      'NAME'        => $this->getName(),
                                      'CURRENT_DATE' => date('l M d Y', $now),
                                      'HOME_MNGR'    => $HOME_MNGR
                                      )
                                );
             
              global $LD_CATEGORY_NAV_DIR, $LD_CATEGORY_NAV_OUTFILE;
             
              $fp = fopen($LD_CATEGORY_NAV_DIR.'/'.$LD_CATEGORY_NAV_OUTFILE, "rb");
              $contents = fread ($fp, filesize ($LD_CATEGORY_NAV_DIR.'/'.$LD_CATEGORY_NAV_OUTFILE));
             
              $template->set_var('LD_NAV', $contents);

        /*
              $msgObj = new Message($this->dbi);
              $msgArr = $msgObj->getMessages($this->uid);
              $this->dump_array($msgArr); */
              global $USER_DB_URL;
              $user_dbi = new DBI($USER_DB_URL);
             
              if (!empty($msgArr))
              {
                foreach($msgArr as $msg)
                {
                //$this->dump_array($msg);
                    if ($msgObj->isViewable($msg->MSG_ID, $this->getUID()))
                    {
                 
                  $userObj = new User($user_dbi, $msg->AUTHOR_ID);
                  $auth = $userObj->getEMAIL();             
                  $template->set_var('MSG_DATE', date("M-d-Y",$msg->MSG_DATE));
                  $template->set_var('MSG_ID', $msg->MSG_ID);
                  $template->set_var('MSG_TITLE', $this->unhtmlentities(stripslashes($msg->MSG_TITLE)));
                  $template->set_var('MSG_AUTHOR', $auth);
                  $template->set_var('MSG_CONTENTS', $this->unhtmlentities(stripslashes($msg->MSG_CONTENTS)));
                  $template->set_var('TABLE_BGCOLOR', $msg->MSG_TYPE ? ADMIN_MSG_COLOR : STANDARD_MSG_COLOR);
                  $template->parse('msg', 'msgBlock', true);
                } 
                }
              }
              else
              {
                $template->set_var('msg', null);
              }

              $thisUser = new IntranetUser($this->dbi, $this->uid);

              $pref = $thisUser->getPreferences($this->uid);

              session_register('SESSION_AUTO_TIP_SHOWN');

              if (!empty($pref['autotip']) && !($this->getSessionField('SESSION_AUTO_TIP_SHOWN')))
              {
              $this->debug("Show tip window");
              $_SESSION["SESSION_AUTO_TIP_SHOWN"] = 1;
              $template->set_var('JS_TIP_SCRIPT', $this->popAutoTip());
              } else {
              $template->set_var('JS_TIP_SCRIPT', null);
              }

              $themeTemplate->set_var('SERVER_NAME', $this->get_server());
              $themeTemplate->set_var('BASE_HREF', $REL_TEMPLATE_DIR);
              $template->set_var('USER_NAME', ucfirst($thisUser->getName()));

              $themeTemplate->set_var('CONTENT_BLOCK', $template->parse('mblock', 'mainBlock'));
              $themeTemplate->parse('cnblock', 'contentBlock');
              $themeTemplate->parse('mmblock', 'mmainBlock');
              $themeTemplate->pparse('output', 'fh');

          }
         
          function unhtmlentities ($string)
          {
    $trans_tbl = get_html_translation_table (HTML_ENTITIES);
    $trans_tbl = array_flip ($trans_tbl);
    return strtr ($string, $trans_tbl);
          }


          function getName()
          {
          list($name, $host) = explode('@', $this->getEMAIL());
          return ucfirst($name);
          }

          function popAutoTip()
          {
            global $TIP_SCRIPT;

              if (! file_exists($TIP_SCRIPT)) return null;

            $fp = fopen($TIP_SCRIPT, "r");
            if ($fp)
            {
            $contents = fread($fp, filesize($TIP_SCRIPT));
            }

            return $contents;
          }

      }//class

      global $INTRANET_DB_URL;

      $thisApp = new IntranetUserHomeApp(
                                          array( 'app_name'            => $APPLICATION_NAME,
                                                'app_version'        => '1.0.0',
                                                'app_type'            => 'WEB',
                                                'app_db_url'          => $INTRANET_DB_URL,
                                                'app_auto_connect'    => TRUE,
                                                'app_auto_chk_session' => TRUE,
                                                'app_auto_authorize'  => FALSE,
                                                'app_debugger'        => $OFF
                                              )
                                          );

      $thisApp->buffer_debugging();
      $thisApp->run();
      $thisApp->dump_debuginfo();
    ?>
    [/code]
    Let me know if you need any more scripts to help work out my problem.
  2. If you look at this error :

    PHP Warning: require_once(C:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/classes/class.Message.php) [function.require-once]: failed to open stream: Invalid argument in C:\Inetpub\wwwroot\database\scripts\home\home.php on line 5 PHP Fatal error: require_once() [function.require]: Failed opening required 'C:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/classes/class.Message.php' (include_path=';C:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/library/PEAR;C:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/library/php;C:/Inetpub/wwwrootC:/Inetpub/wwwroot/database/classes;;C:/Inetpub/wwwroot/database/classes;.;c:\php\includes;c:\Inetpub\wwwroot\PEAR') in C:\Inetpub\wwwroot\database\scripts\home\home.php on line 5

    You can see it omits a ';' between '/wwwroot''C:/Inetpub' but these are the only two ini_sets I have :
    [code]
    $PATH        = $PEAR_DIR . ';' . $PHPLIB_DIR . ';' . $CLASSES;
      ini_set( 'include_path', ';' . $PATH . ';' . ini_get('include_path'));
    [/code]
    and :
    [code]
    $CLASSES          = $REL_APP_PATH . '/classes';

      ini_set( 'include_path', ';' . $CLASSES . ';' . ini_get('include_path'));
    [/code]
    And have checked php.ini and all looks fine, where could this error be comming from, although the error is solved, why the missing ';' ?
  3. Thanks Businessman,  it helps to just clear things up in my mind.  Also back to the end of my original post, where does this url lead to?

    http://my-server.my.local/database/scripts/home/%5CdatabaseC:%5C%5CInetpub%5Cwwwroot%5Cdatabase%5Cscripts%5Clogin%5Clogin.php?url=http://my-server.my.local

    I want it to goto the login.php, which is located where the URI is pointed, except not in the home folder.  And why would it specify the whole location like that?

    I have an unmodified version that calls to /home/home.php but displays the login.php, and I can't find any differences, and I don't know which code it's in either?

    Here's a snippet of home.php
    [code]

      require_once "home.conf.php";

      require_once $MESSAGE_CLASS;
      require_once $INTRANET_USER_CLASS;

      /* Session variables must be defined before session_start() method is called */
     
      class IntranetUserHomeApp extends PHPApplication {

          function run()
          {
              global $TEMPLATE_DIR;
             
              $read = $this->getRequestField('read');

              if (! $this->authorize($this->getSessionField('SESSION_USERNAME')))
              {
                $this->alert('UNAUTHORIZED_ACCESS');
              }

              $this->uid = $this->getUID();

              $themeObj = new Theme($this->dbi,null,'home');

              $this->themeObj = $themeObj;

              $this->theme = $themeObj->getUserTheme($this->uid);

              $this->template_dir = $TEMPLATE_DIR;

              if (!empty($read))
              {
                  $this->updateMsgTrack();
              }

              // At this point user is authorized
              $this->displayHome();
        }


          function authorize()
          {
              return TRUE;
          }
    [/code]
  4. Yeah, they all end in .php anyway, just shortened it for principals sake.  Do these files run differenly or what do they represent, apart from the obvious includes and config, is it just for names sake?

    Back to original post, would it be ok for them to just be put in two files?  Would it slow things down?  Or am I on the right path?
  5. If you create a file in your includes folder, with variables set to the definate path to your files, then from where ever you are you can require once the file in your includes folder, and call the variables that contain your files and they should run. i.e.

    [code]
    $foo = '/a/foo/foo.php';
    $bar = '/a/bar/bar.php';
    [/code]

    In your includes folder, then from your file in httpd

    [code]
    include($foo);
    include($bar);
    [/code]

    Then no-one can hack your file locations cos they don't have permissions, yeah.
  6. I am following a model for a database fountend for my company, but there are many functions that I don't want or want it to do a little differently.  I've only been working with php for about a month and have not really done much programming before apart from html.  So really what I have done is just ripped loads of stuff out of the code, and changed the folder framework about a bit to something I'm a bit more comfortable working with.

    This Framework is highly Object Orientated and this is what I have it doing at the moment.

    index.php --> just call's home.php

    home.php --> checks for authentication TRUE if not send to login.php

    login.php --> scans ActiveDirectory retrieves the name of user, checks to see if it exists in the Database if TRUE pass back to home.php

    home.php --> loads home.conf

    home.conf --> defines styles+templates & calls config.inc

    config.inc --> defines the Framework and Calls many classes

    Is this a good way of doing it or could I just put index, home, login all in one file and home.conf and config.inc together also?

    At the moment when home.php sends to login.php it says it can't find the file, when it's pointing in the right direction, but because the user doesn't really need to see it unless they are not entered in the database, then a message appears (speak to me), does it really have to be in a seperate file.
  7. What he means is use the php.ini settings to include the path, you can do it in the script like so :

    [code]
    ini_set( 'include_path', '/whatever/path/you/like' . ini_get('include_path'));
    [/code]

    And php will look in these directories to execute files.  Also check :

    [code]
    <?php phpinfo(); ?>
    [/code]

    To see your set includes path, which can be edited directly in the ini file.
  8. I use jEdit, can be a bit slow, does all the functions that you would need and theres loads of plugins for other codeing support, + the ability to make your own plugins, someone needs to do a good one for snippets like dreamweavers. as far as } is concerned, it will match any type of brace by putting the curser next to it.  And the find replace within directory is VERY good, it will open up the files it has changed and hi-light each entry to check before you save the files.  Is opensource.
  9. Hi All,

    I recieve this Error :

    PHP Fatal error: Call to a member function fetchRow() on a non-object in C:\root\to\my\framework\lib.session_handler.php on line 36

    What I think my code is doing, is returning the result of a query to a variable called $result and is then using it in the wrong fashion (i.e calling the function on the non-object) that it loops round and returns the error above.  I don't want it to do that.  But I don't really understand what I do want it to do.  Here is my code below :
    [code]
            function sess_read($key) {
                    global $dbi, $DEBUG, $SESS_LIFE;

                    $statement = "SELECT value FROM sessions WHERE sesskey = $key AND expiry >" . time();

                    $result = $dbi->query($statement);

                    if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";
                    $row = $result->fetchRow();
                    if ($row) {
                      return $row->value;
                    }
                    return false;
            }
    [/code]

    Could this occur as a result of not talking to DBI.php or NULL field in sesskey, and not of my php code.  And could someone expain to me what this process it doing,  I already understand the query bit tho  ;)

    Thanks ppl
  10. How would I go about calling
    [code]$domain_user = $_SERVER['LOGON_USER'];[/code]

    Then taking of the prepend of the SERVER\ string to be left with just the user name, to query the Database for that user.

    Or would it be easier but slower to retrive a list of the users from the database and compare it to the returned $domain_user to see if they exist in the database?
  11. Yeah, I should have noticed that before, however I have tried that, with the time() inside also, however it still keeps spilling over the page now halfway through the string where time is.

    [code]
    time";$result = $dbi->query($statement);blah,blah,blah
    [/code]

    Then the opening page (login.php) still displays underneath it with no errors, although it doesn't login, but thats a different problem.

    It seems as if it is happening from that particular character, i.e If I put something else in the string it returns it on the page.

    [code]
    buggered string" . time();$result = $dbi->query($statement);blah,blah,blah
    [/code]

    could it be due to this character ">" or a white-space (I don't understand how whitespaces work)

    Thanks for spending some time on this for me.
  12. Hmm,  I think King Arther is the closest, although I tried that and it did not solve it, did you mean "(time())" those brackets, sorry am quite new to php so not entirely clear on specific syntax.

    I am using the <?php ?> tags, because it just doesn't work otherwise and is better practice anyway.

    And sorry RockingGroudon I did not understand what you meant by using eval, as it's not in my code anywhere.

    I put in the whole code as I thaught that it may be a missing " somewhere, although I have gone through with a fine tooth comb. jEdit, shows open, closing sytax via curser.
  13. Hi I've narrowed this down but still can't find the error.

    I made a file that just called the lib.session_handler.php so no interference from other code, and it still just spills out all the source over my page, instead of running it. Why does it do that?  It's the First block of source on my original post, and spews from the second bit of code.

    Please Help  :o
  14. You can use a seperate file for hadling sessions, for portability.  I have one se up that thats creates a session for each user.  The session will then last as long as you set it up for in php.ini.  Here one I borrowed from http://www.evoknow.com/downloads.php

    Need to connect to the database first.

    [code]
    $SESS_LIFE = get_cfg_var("session.gc_maxlifetime");

            function sess_open($save_path, $session_name) {
              return true;
            }

            function sess_close() {
              return true;
            }

            function sess_read($key) {
                    global $dbi, $DEBUG, $SESS_LIFE;

                    $statement = "SELECT value FROM sessions WHERE " .
                          "sesskey = $key AND expiry > " . time();

                    $result = $dbi->query($statement);

                    if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";
                    $row = $result->fetchRow();
                    if ($row) {
                      return $row->value;
                    }

                    return false;
            }

            function sess_write($key, $val) {
                    global $dbi, $SESS_LIFE;

                    $expiry = time() + $SESS_LIFE;
                    $value = addslashes($val);

                    $statement = "INSERT INTO sessions VALUES ('$key', $expiry, '$value')";
                    $result = $dbi->query($statement);

                    if ($DEBUG) echo "sess_write: $statement <br>result: $result<br>";

                    if (! $result) {
                            $statement = "UPDATE sessions SET expiry = $expiry, value = '$value' " .
                                  "WHERE sesskey = '$key' AND expiry > " . time();
                            $result = $dbi->query($statement);
                    }

                    return $result;
            }

            function sess_destroy($key) {
                    global $dbi;

                    $statement = "DELETE FROM sessions WHERE sesskey = '$key'";
                    $result = $dbi->query($statement);
                    if ($DEBUG) echo "sess_destroy: $statement <br>result: $result<br>";

                    return $result;
            }

            function sess_gc($maxlifetime) {
                    global $dbi;

                    $statement = "DELETE FROM sessions WHERE expiry < " . time();
                    $qid = $dbi->query($statement);
                    if ($DEBUG) echo "sess_gc: $statement <br>result: $result<br>";

                    return 1;
            }

            session_set_save_handler(
                    "sess_open",
                    "sess_close",
                    "sess_read",
                    "sess_write",
                    "sess_destroy",
                    "sess_gc");
    [/code]

    You need to make some other files first to talk to it.
    But shud give you all you need.
  15. Hi I have found out that php does not implement any support for Windows users or groups, for anyone else wondering about this sort of configuration read this article http://www.microsoft.com/technet/archive/interopmigration/linux/mvc/miglamp.mspx?mfr=true

    Good Luck
  16. Hi All,

    I have a file called lib.session_handler and another called class.PHPApplication.php that I have not edited recently, but are called by a number of other files in my script.  Well class.PHPApplication.php is called which in turn calls lib.session_handler.

    However when I run my scripts it keeps on displaying half of the source of lib.session_handler.php.  I have searcher for a open string anywhere to no avail.  Why could this be?  Here is some source if it may help :

    lib.session_handler.php

    [code]
    require_once('constants.php');
    require_once('class.DBI.php');
    require_once 'DB.php';

    $DEBUG = 0;

    $DB_URL = "mssql://user:pass@localhost:/sessions";

    $dbi =  new DBI($DB_URL);

    $SESS_LIFE = get_cfg_var("session.gc_maxlifetime");

            function sess_open($save_path, $session_name) {
              return true;
            }

            function sess_close() {
              return true;
            }

            function sess_read($key) {
                    global $dbi, $DEBUG, $SESS_LIFE;

                    $statement = "SELECT value FROM sessions WHERE " .
                          "sesskey = '$key' AND expiry > " . time();

                    $result = $dbi->query($statement);

                    if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";
                    $row = $result->fetchRow();
                    if ($row) {
                      return $row->value;
                    }

                    return false;
            }

            function sess_write($key, $val) {
                    global $dbi, $SESS_LIFE;

                    $expiry = time() + $SESS_LIFE;
                    $value = addslashes($val);

                    $statement = "INSERT INTO sessions VALUES ('$key', $expiry, '$value')";
                    $result = $dbi->query($statement);

                    if ($DEBUG) echo "sess_write: $statement <br>result: $result<br>";

                    if (! $result) {
                            $statement = "UPDATE sessions SET expiry = $expiry, value = '$value' " .
                                  "WHERE sesskey = '$key' AND expiry > " . time();
                            $result = $dbi->query($statement);
                    }

                    return $result;
            }

            function sess_destroy($key) {
                    global $dbi;

                    $statement = "DELETE FROM sessions WHERE sesskey = '$key'";
                    $result = $dbi->query($statement);
                    if ($DEBUG) echo "sess_destroy: $statement <br>result: $result<br>";

                    return $result;
            }

            function sess_gc($maxlifetime) {
                    global $dbi;

                    $statement = "DELETE FROM sessions WHERE expiry < " . time();
                    $qid = $dbi->query($statement);
                    if ($DEBUG) echo "sess_gc: $statement <br>result: $result<br>";

                    return 1;
            }

            session_set_save_handler(
                    "sess_open",
                    "sess_close",
                    "sess_read",
                    "sess_write",
                    "sess_destroy",
                    "sess_gc");
    [/code]

    It prints from [code]
    ". time();

                    $result = $dbi->query($statement);
    [/code]

    (notice the quote " ) right till the end.  I made a file to just call it:

    [code]
    <?php

    require_once 'lib.session_handler.php';

    ?>
    [/code]

    Thanks in Advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.