Ive been looking at the code for like an hour and then even started over to see if I messed something up, but I am getting the same result, and thats nothing. Most these pages are stolen from scripts that I have made before, but the defines are something I have changed...
<?PHP
defined('__sn') or die();
define('__sn', 1);
$CONF['__THEME']="opening";
$MYSQL['__HOST']="localhost";
$MYSQL['__DBAS']="XXXXXXXX";
$MYSQL['__USER']="XXXXXXXX";
$MYSQL['__PASS']="XXXXXXXXXXXX";
$SITE['__NAME']="SoldiersNet";
$SITE['__MAINURL']="http://soldiersnet.net/"; //Must include trailing "/"
###############################
# DO NOT EDIT BELOW THIS LINE #
###############################
$CONF['__VERSION']="1.0a";
include "includes/db.php";
$db=new db($MYSQL['__HOST'],$MYSQL['__USER'],$MYSQL['__PASS'],$MYSQL['__DBAS']);
$db->newconn();
include "includes/layout.php";
$layout=new layout($db);
include "includes/functions.php";
$user=new user($db);
$app=new app($db);
?>
includes/db.php
PHP Code:
<?PHP
defined('__sn') or die();
class db{
var $host = "";
var $user = "";
var $pass = "";
..... too big of a file....
includes/layout.php
PHP Code:
<?PHP
defined('__sn') or die();
define('__sn', 1);
include "../config.php";
class layout{
function layout($db){
$this->db=$db;
}
function head(){
.... too big of a file....
includes/functions.php
PHP Code:
<?PHP
defined('__sn') or die();
class user {
$db=0;
function user($db){
$this->db=$db;
}
}
class app {
$db=0;
function app($db){
$this->db=$db;
}
function userApps($ui){
echo "<!-- APP LOADER: Loading Apps-->";
$uinfo=explode("|",$ui);
$this->db("SELECT * FROM users WHERE id='".$uinfo[0]."'");
while($row=$this->db->fetch_array()){
$uperm=explode(",",$row['permissions']);
if($uperm=="(*)"){
}else{
$permid=explode(",",$uperm);
foreach($permid as $value){
$this->db->query("SELECT * FROM apps WHERE id='".$value."'");
while($rowa=$this->db->fetch_array()){
if (file_exists("<acronym title="JavaScript">js</acronym>/apps/".$rowa['location']."/index.<acronym title="JavaScript">js</acronym>.php")){
echo "
<!-- Loaded: ".$rowa['name']." -->";
echo "
<script type=\"text/javascript\" src=\"apps/".$rowa['location']."/index.<acronym title="JavaScript">js</acronym>.php\"></script>";
}else{
echo "
<!-- Error: ".$rowa['name']." does not exist! -->";
}
}
}
}
}
unset($uinfo,$row,$rowa,$uperm,$permid,$value);
}
}
?>
You can not re-define constants. That would defeat the purpose. Define it once in the index.php (and other MAIN) pages, and do the check only on the included pages.
Ok, Ive changed some stuff around and still am having no luck, here are the current files and I know there is a lot of stuff commented out, Ive been doing some troubleshooting trying to find out what file is messed up, at least...
index.php
PHP Code:
<?PHP
session_start();
//define('__sn', 1);
include('config.php'); // Include all config vars.
include('inc.php'); // Include all classes and functions.
$layout->headStart();
if(isset($_SESSION['UINFOSTAFF'])){
echo "hello";
}else{
echo "hello";
}
$layout->footStart();
?>
<?PHP
//defined('__sn') or die();
//define('__sn', 1);
$CONF['__THEME']="opening";
$CONF['__DEBUG']="1"; // 0=OFF; 1=ON
$MYSQL['__HOST']="localhost";
$MYSQL['__DBAS']="XXXXXXXX";
$MYSQL['__USER']="XXXXXXXX";
$MYSQL['__PASS']="XXXXXXXXXXXXXXXXXXXX";
$SITE['__NAME']="SoldiersNet";
$SITE['__MAINURL']="http://soldiersnet.net/"; //Must include trailing "/"
###############################
# DO NOT EDIT BELOW THIS LINE #
###############################
$HARD['__VERSION']="1.0a";
?>
include/backend.php
PHP Code:
<?PHP
//defined('__sn') or die();
//define('__sn', 1);
include "../config.php";
include "../inc.php";
switch($_GET['op']){
case'login':
$un=$_POST['userName'];
$pw=$_POST['userPassword'];
$db->query("SELECT * FROM users WHERE username='".$un."'");
if($db->num_rows()>0){
while($row=$db->fetch_array()){
if($row['password']==md5($pw)){
// Login passed.
$l_login=time();
if($db->query("UPDATE users SET last_login='".$l_login."', last_ip='".$_SERVER['REMOTE_ADDR']."'")){
$user_info=array($row['id'],$row['username'],$row['password']);
$_SESSION['UINFOSTAFF']=implode("|",$user_info);
$result["success"] = true;
}else{
$result["success"] = false;
$result["errors"]["reason"] = "The database denied the request, please try again. [backend.php?op=login:103]";
}
}else{
// Login failed because the passwords didn't match.
$result["success"] = false;
$result["errors"]["reason"] = "Your password didn't match the one in the database. [backend.php?op=login:102]";
}
}
}else{
// Login failed because email wasn't in the db.
$result["success"] = false;
$result["errors"]["reason"] = "That email wasn't in the database. [backend.php?op=login:101]";
}
echo json_encode($result);
break;
case'logout':
if(isset($_SESSION['UINFOSTAFF'])){
$_SESSION['UINFOSTAFF']=="";
echo "Logged out";
}else{
echo "never logged in";
}
break;
}
?>
include/db.php
PHP Code:
<?PHP
//defined('__sn') or die();
//define('__sn', 1);
class db{
var $host = "";
var $user = "";
var $pass = "";
var $datb = "";
var $errordesc = "";
var $errorno = "";
// Query vars
var $queryid = 0;
var $results = array();
function db($host,$user,$pass,$datb){
$this->host=$host;
$this->user=$user;
$this->pass=$pass;
$this->datb=$datb;
}
// Create Database Connection \\
function newconn(){
$this->connection = @mysql_connect($this->host, $this->user, $this->pass);
if(!$this->connection){
$this->error("Couldn't connect to host: ".$this->host."");
}else
if(!@mysql_select_db($this->datb, $this->connection)){
$this->error("Couldn't connect to database: ".$this->datb."");
}
}
// Create a Database Query \\
function query($query){
$this->queryid = @mysql_query($query, $this->connection);
return $this->queryid;
}
// Count Rows \\
function num_rows(){
$this->num=mysql_num_rows($this->queryid);
return $this->num;
}
// Fetch an array out of a database \\
function fetch_array($id=-1){
if($id==-1){
$res=@mysql_fetch_array($this->queryid);
}else{
$res=@mysql_fetch_array($id);
}
return $res;
}
// Insert into a table \\
function insert($table, $data){
}
// Update a table \\
function update($table, $data, $where){
}
// Delete out of a table \\
function delete($table, $where){
}
// Output errors \\
function error($str=""){
$this->errordesc=mysql_error();
$this->errorno=mysql_errno();
if($CONF['__DEBUG']=="1"){
echo "<b>Error Message:</b> ".$str."<br><br><b>MySQL Error (#".$this->errorno."):</b> ".$this->errordesc."";
}else{
echo "<b>Error Type:</b> Configuration Error<br><br><b>There was an error on the $conf['debug'] line in your config file.";
}
}
}
?>
include/functions.php
PHP Code:
<?PHP
//defined('__sn') or die();
//define('__sn', 1);
include "../config.php";
include "../inc.php";
class user {
var $db=0;
function user($db){
$this->db=$db;
}
}
class app {
var $db=0;
function app($db){
$this->db=$db;
}
function userApps($ui){
echo "<!-- APP LOADER: Loading Apps-->";
$uinfo=explode("|",$ui);
$this->db("SELECT * FROM users WHERE id='".$uinfo[0]."'");
while($row=$this->db->fetch_array()){
$uperm=explode(",",$row['permissions']);
if($uperm=="(*)"){
}else{
$permid=explode(",",$uperm);
foreach($permid as $value){
$this->db->query("SELECT * FROM apps WHERE id='".$value."'");
while($rowa=$this->db->fetch_array()){
if (file_exists("js/apps/".$rowa['location']."/index.js.php")){
echo "
<!-- Loaded: ".$rowa['name']." -->";
echo "
<script type=\"text/javascript\" src=\"apps/".$rowa['location']."/index.js.php\"></script>";
}else{
echo "
<!-- Error: ".$rowa['name']." does not exist! -->";
}
}
}
}
}
unset($uinfo,$row,$rowa,$uperm,$permid,$value);
}
}
?>
Edit: When testing or developing, you should have all error reporting turned on. I noticed you have some error suppression in your scripts. I would take all of that out. Something is getting sent. It always is. The error's are getting dropped due to suppression.
On the page that is including the other page, but __SN isn't active right now because I took them out. I dont think that the defines are the problem anymore, now Im clueless to what is wrong...