Jump to content

Recommended Posts

Ok I have been working on a friends area for my site. Everything works fine except this page. Here is the code.

 

<?php
include "/home/arcaded/public_html/cfg.php";

// Make sure the user is logged in.
if (user_enabled()) {
$user = get_logged_in_user();
if ($user == true || $user['friend'] != "Yes") {
	include "../login.php";
	die();
}
}
?>
<html>
<head>
  <title> Arcade Dump Friends Area </title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script language="JavaScript">
   <!--
   function popup(URL, ww, wh) {
  	 day = new Date();
  	 id = day.getTime();
  	 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ww+",height="+wh+",left = 40,top = 40');");
   }

   function docollapse(thingstring) {
   thing = document.getElementById(thingstring);

   if (thing.style.height == '') {
	   thing.style.visibility = 'hidden';
	   thing.style.height = '0px';
	   thing.style.display = 'none';
   } else {
	   thing.style.visibility = 'visible'
	   thing.style.height = '';
	   thing.style.display = 'block';
   }

   }
   // -->
  </script>
  <link rel="stylesheet" type="text/css"
href="http://arcadedump.net/plugins/site/themes/admin/style.css">
</head>
<body>
<div align="center">
<table class="maintable" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td class="topstrip" colspan="2" align="center" valign="middle"> <a
href="../"><img
src="http://www.arcadedump.net/plugins/site/themes/admin/logo.png"
border="0" height="81" width="266"></a> </td>
    </tr>
    <tr>
      <td class="topmenustrip" colspan="2">
      <center><img
src="http://www.arcadedump.net/plugins/site/themes/admin/linkborder.png"
align="top"><span style="position: relative; top: 6px;"> <a
href="#" class="toprightlink">Home</a></span>
      <img
src="http://www.arcadedump.net/plugins/site/themes/admin/linkborder.png"
align="top"></center>
      </td>
    </tr>
    <tr>
      <td class="maincontentarea" colspan="2" valign="top">
      <table style="margin: 0px; padding: 0px;" border="0"
cellpadding="0" cellspacing="6" width="100%">
        <tbody>
          <tr>
            <td valign="top" width="100%">
            <table cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td style="padding-right: 6px;" valign="top"
width="100%"> <br>
                  </td>
                </tr>
                <tr>
                  <td class="homecatcontent" valign="top"><!--div class='homecathead'>
	     <div class='homecatheadtext'>FriendCP</div>
	 <?
$phpself = $_SERVER['PHP_SELF']; //its you php page.
switch($_GET['id']) {
case 'chat':
print "testing";
break;
case 'vids':
print "testing";
break;
}
echo "<b>FriendCP</b>
<br /><br />
Welcome to the FriendCP! This is where the friends of Zack can hang out <br>and watch videos you can't find anywhere else on the site.
";
?>
</td>
                </tr>
              </tbody>
            </table>
            </td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
    <tr>
      <td class="footstrip" colspan="2" valign="middle"> <a href="../"
class="bottomlink">« Main Site</a> </td>
    </tr>
  </tbody>
</table>
</div>
</body>
</html>

 

It seems to be the php code at the top. Can somebody please tell me how to fix the php code to display the rest of the page after checking if they are logged in/in right group.

 

Zack~

 

Zachary

Link to comment
https://forums.phpfreaks.com/topic/50726-help-with-script/
Share on other sites

You could keep it simple, instead of using functions for something like that (or else show me the functions).

What I do is register a session

$_SESSION['logged'] = "yes";

then you can check it numerous way's.

At the top you can have

if ($_SESSION['logged'] == "yes") {

// show page

}else {

header("location: send them");

}

there are other options, if you want a quicker way a simple.

if ($_SESSION['logged'] != "yes") {

header("Location: whatever");

exit();

}

 

There are multiple way's, if not then show me the functions you are trying to use for that part.

Link to comment
https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249403
Share on other sites

You could keep it simple, instead of using functions for something like that (or else show me the functions).

 

We have no way of knowing what all is being checked within the function. There may be a dozen different things that determine whether or not the user is enabled. Recommending that he forgo using the function is really not a very helpful suggestion unless you know what the function entails and you know he will not be missing any additional functionality with it.

 

My guess is that the function is returning a boolean and you simply have your logic reversed. Try putting a '!' in front of the function call so the script will forward to the login page and die only if they are not enabled:

<?php
if (!user_enabled()) {
$user = get_logged_in_user();
if ($user == true || $user['friend'] != "Yes") {
	include "../login.php";
	die();
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249429
Share on other sites

function user_enabled() {
if (get_user_config('name=enabled')==1) {
	return true;
} else {
	return false;
}

return false;
}

 

function get_logged_in_user($args='') {

global $db;

if (!isset($_COOKIE["usercookie"])) {
	return false;
}

if (!user_enabled()) {
	return false;
}


$cookie = $_COOKIE["usercookie"];
$cookie = explode(":", $cookie);
$username = $cookie[0];
$password = $cookie[1];

$result = $db->query("
SELECT * FROM members WHERE
username='".$username."' AND password='".$password."' AND active='Yes'");

if (mysql_num_rows($result) == 1) {
	return mysql_fetch_array($result);
} else {
	return false;
}

}

 

Those are the only 2 functions that I found for user_enabled

Link to comment
https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-250097
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.