PHP Help
Iamazn Offline
Junior Member
**
Posts: 9
Joined: Jul 2010
Post: #1
PHP Help
-Trying to retrieve user info via their last visit IP.
-This PHP script is not in myforum.net/forum/, it's in subdomain.myforum.net.
Why isn't anything "echoed"?

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
error_reporting(E_ALL); 
define('IN_MYBB', 1); 
require_once '/home/vol4/byethost11.com/username/myforum.net/htdocs/forum/global.php'; 

//Get the IP of the user.
$ip = $_SERVER['REMOTE_ADDR'];

$query = $db->query("SELECT username,postnum,usergroup,additionalgroups,lastip FROM mybb_users WHERE lastip='$ip'");
$user = $db->fetch_array($query);
if($user['username'] == NULL)
{
die("Invalid User");
}

$username = $user['username'];
$posts = $user['postnum'];
$usergroup = $user['usergroup'];
$additional = $user['additionalgroups'];

echo $username . "<br>";
echo $posts . "<br>";
echo $usergroup . "<br>";
echo $additional . "<br>";
?>

12-05-2010 12:18 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: PHP Help
(12-05-2010 12:18 PM)Iamazn Wrote:  

PHP Code:
<?php
require_once '/home/vol4/byethost11.com/username/myforum.net/htdocs/forum/global.php'; 

That will most likely break.  Best to chdir() to the correct directory.  Defining MYBB_ROOT manually may work too (cbf checking).

My Blog
(This post was last modified: 12-05-2010 01:35 PM by ZiNgA BuRgA.)
12-05-2010 01:35 PM
Find all posts by this user Quote this message in a reply
Iamazn Offline
Junior Member
**
Posts: 9
Joined: Jul 2010
Post: #3
RE: PHP Help
(12-05-2010 01:35 PM)ZiNgA BuRgA Wrote:  
(12-05-2010 12:18 PM)Iamazn Wrote:  

PHP Code:
<?php
require_once '/home/vol4/byethost11.com/username/myforum.net/htdocs/forum/global.php'; 

That will most likely break.  Best to chdir() to the correct directory.  Defining MYBB_ROOT manually may work too (cbf checking).
How do I "define" MYBB_ROOT?
12-05-2010 03:00 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: PHP Help
http://au.php.net/manual/en/function.define.php

My Blog
12-05-2010 03:40 PM
Find all posts by this user Quote this message in a reply
Iamazn Offline
Junior Member
**
Posts: 9
Joined: Jul 2010
Post: #5
RE: PHP Help
(12-05-2010 03:40 PM)ZiNgA BuRgA Wrote:  http://au.php.net/manual/en/function.define.php
Can chdir() "go back" directories?
I tried:

Code:
chdir(/home/vol4/byethost11.com/username/myforum.net/htdocs/forum/);

and it didn't change the directory. (used "echo getcwd();")

Here's my FTP "structure":
Home: /home/vol4/byethost11.com/username/
Forum: /home/vol4/byethost11.com/username/myforum.net/htdocs/forum/
The PHP Script: /home/vol4/byethost11.com/username/test.myforum.net/htdocs/

12-05-2010 03:53 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: PHP Help
(12-05-2010 03:53 PM)Iamazn Wrote:  Can chdir() "go back" directories?
Yes.  Do you have some safe mode restrictions?
IDK much about safe mode - maybe it only likes relative paths.  Try that and see if that works.
EDIT:
http://php.net/manual/en/function.chdir.php Wrote:Note: When safe mode is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.
Quote:When using PHP safe mode and trying to change to a dir that is not accessible due to the safe mode restrictions, the function simply fails without generating any kind of error message.
Perhaps check those.

My Blog
(This post was last modified: 12-05-2010 05:37 PM by ZiNgA BuRgA.)
12-05-2010 05:34 PM
Find all posts by this user Quote this message in a reply
MattR Offline
Junior Member
**
Posts: 40
Joined: Jul 2010
Post: #7
RE: PHP Help
I did say to use a relative path in your thread on the MyBB forums... even offered to login to your file system to see what it'd need to be for you.
(This post was last modified: 12-05-2010 10:36 PM by MattR.)
12-05-2010 10:35 PM
Find all posts by this user Quote this message in a reply
Iamazn Offline
Junior Member
**
Posts: 9
Joined: Jul 2010
Post: #8
RE: PHP Help
Would chdir('/home/vol4/byethost11.com/username/myforum.net/htdocs/forum/');
work?
How do I get relative paths?
12-06-2010 03:16 AM
Find all posts by this user Quote this message in a reply
MattR Offline
Junior Member
**
Posts: 40
Joined: Jul 2010
Post: #9
RE: PHP Help
It's the path to the file you want relative to where you are currently. Say your structure was this:
  • public_html/
    • forum/
      • global.php
    • site/
      • file.php

You're in file.php, you need to include global.php, the relative path would be this:

Code:
../forum/global.php


You're currently in /site/, ../ means go back a folder, so you go back to /public_html/, then into /forum/, and then global.php

12-06-2010 05:36 AM
Find all posts by this user Quote this message in a reply
Iamazn Offline
Junior Member
**
Posts: 9
Joined: Jul 2010
Post: #10
RE: PHP Help
(12-06-2010 05:36 AM)MattR Wrote:  It's the path to the file you want relative to where you are currently. Say your structure was this:
  • public_html/
    • forum/
      • global.php
    • site/
      • file.php

You're in file.php, you need to include global.php, the relative path would be this:

Code:
../forum/global.php


You're currently in /site/, ../ means go back a folder, so you go back to /public_html/, then into /forum/, and then global.php

This is the structure:
/ = root
/sub.myforum.net/htdocs/scr.php = script
/myforum.net/htdocs/forum/global.php = Global.php
12-06-2010 02:18 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: