Jump to content

Can someone take a look at this file


doddsey_65

Recommended Posts

in the essence of trying to code my forum better i have started again(again). i havent just ditched the old files however. what i am doing is starting with one file and getting it right until i move to the next. then i will pull some old code(css and html mainly) from the old files. with that in mind i would like someone to have a look over what i have so far on the index.php page. it doesn't display anything, just sets up variables and such. I would like to know how it can be improved before i move on to more.

 

<?php
/* ASF A Simple Forum
* Version 0.1.0
* Page Created 21/01/2011
*/

// can page be accessed directly?
define("ACCESS", 1);

// start sessions
session_start();

// get the functions file
require_once("./functions/functions.php");

// get whos online list
$online_list = array();

$online_query = simple_query("user_username", "members", "user_online=1 AND user_hidden != 1", "0user_username", "array");

while($online_info = mysqli_fetch_array($online_query, MYSQLI_ASSOC))
{
    // add online users into array for later callback
    $online_list[] .= profile_link("", $online_info['user_username'], "");
}

$online_num = mysqli_num_rows($online_query);

// find hidden users
$hidden_query = simple_query("user_username", "members", "user_online=1 AND user_hidden = 1", "0user_username", "array");
$hidden_num = mysqli_num_rows($hidden_query);

// if logged in as admin
if(@$_SESSION['permissions'] == 1)
{
    $hidden_list = array();
    // show hidden list
    while($hidden_info = mysqli_fetch_array($hidden_query, MYSQLI_ASSOC))
    {
        // add hidden users to array and append with * to denote hidden
        $hidden_list[] .= "*".profile_link("", $hidden_info['user_username'], "");
    }
}

// get birthday list
$this_day = date("d", time());
$this_month = date("m", time());

$birthday_list = array();

$birthday_query = simple_query("user_username", "members", "user_dob_day=$this_day AND user_dob_month=$this_month", "0user_username", "array");

while($birthday_info = mysqli_fetch_array($birthday_query, MYSQLI_ASSOC))
{
    $birthday_list[] .= profile_link("", $birthday_info['user_username'], "");
}

// get current user info
if(@$_SESSION['logged_in'] == 1)
{
    $uid = $_SESSION['user_id'];
    $user_query = simple_query("*", "members", "user_id=$uid", "", "array");
    $user_info = mysqli_fetch_array($user_query, MYSQLI_ASSOC);
    
    // is the user a mod or admin?
    switch($user_info['user_group'])
    {
        case "1":
        $_SESSION['permissions'] = 1; // admin permissions
        break;
        case "2":
        $_SESSION['permissions'] = 2; // mod permissions
        break;
        case "3":
        $_SESSION['permissions'] = 3; // standard permissions
        break;
        default;
        $_SESSION['permissions'] = 3; // standard permissions
        break;
    }
    
    $u_name = profile_link("", $user_info['user_username'], "");
    
    // is the user banned?
    if($user_info['user_banned'] == 1)
    {
        $_SESSION['permissions'] = 0; // no permissions
        
        // get ban length
        $ban_query = simple_query("*", "bans", "user_id=$uid", "", "array");
        $ban_info = mysqli_fetch_array($ban_query, MYSQLI_ASSOC);
        
        $ban_start = asf_date($ban_info['ban_start'],1);
        $ban_end = asf_date($ban_info['ban_end'],1);
        
        echo ban_notice($ban_start, $ban_end, "");
    }
}

// get forum statistics
$forum_stats = get_forum_stats();


?>

 

[attachment deleted by admin]

Link to comment
Share on other sites

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