Welcome Guest, Not a member yet? Register   Sign In
Help please >.<
#1

[eluser]stevenazari[/eluser]
Hi there guys, I got a real problem on my hands here so the thread is gonna be a bit long...

Ok so I have taken a job over in a company from a contract coder who no longer works/corresponds with the company, I have been told he was using code igniter with the site - of which I have no experience with.

now - I think code igniter requires the develiper to work from a folder within its directory - and for some reason the old coder told a fellow colleague of mine to work from the root directory (i.e - www.name.com/colleaguesdirectory).

Problem 1.
Now from what I can see (based on the file structure) - the login session isnt being lost when the user navigates to my colleagues directory pages (www.name.com/colleaguesdirectory/index.php) which is absolutely useless because it means the user loses their navigation menu. But when the user navigates BACK into the code igniter directory, the menu is brought back.

Problem 2.
I cant seem to find his method of session creation, All I know is that it is being created for within the code igniter directory, but all I want is to take that session variable and use it across the domain.

Here is 2 pages of which SEEM to be relevant to the login process and session creation - but as far as I can see, Im shooting in the dark.

Page 1: Sidebar.php
-
Code:
<h2><span>Band/Artist</span></h2>
<div class="sidebaritem">
  &lt;form id="sidebarsearch" action="/search/dosearch/" method="post"&gt;
    &lt;input type="text" name="searchstring" id="searchstring" value="&lt;?=$sidebarsearchstring?&gt;"&gt;
    &lt;input type="submit" class="submit" value="Search"&gt;
        <p><a href="/artists/browse_artists/index.php" style="text-decoration:none; font-size:11px">> Advanced Search</a></p>
  &lt;/form&gt;
</div>

&lt;?php if ($this->session->userdata('logged_in') && ($this->session->userdata('usertype') != 3)) : ?&gt;

&lt;?php
if ($this->session->userdata('userid'))
{
  $band_id = $this->session->userdata('bandid');
  $this->db->where('id', $band_id);
  $query = $this->db->get('band');
  $this_band = $query->row();
  $band_perma = $this_band->permalink;
}
?&gt;

<h2><span>My GBOB</span></h2>

<div class="sidebaritem mygbob">
  <ul class="nav">
&lt;?php
$this->db->where('pagetype', 'band');
$this->db->where('active', 'yes');
$this->db->order_by('order', 'asc');
$query = $this->db->get('gbob_pages');
$band_pages = $query->result();

$nav = '';
foreach($band_pages as $p)
{
  $nav .= '<li class="';
  if ($p->protected == 'yes')
  {
    $nav .= 'edit';
    if ($p->link == $this_page->link)
    {
      $nav .= ' ';
    }
  }
  if ($p->link == $this_page->link && (!empty($this_page->link) || $this_page->order == 1) && $page == 'band' && $band->id == $this->session->userdata('bandid'))
  {
    $nav .= 'active';
  }
  $nav .= '"><a >link))
  {
    $nav .= $p->link . '/';
  }
  $nav .= '">' . $p->title . '</a></li>';
}
$nav = str_replace('li class=""', 'li', $nav);
print $nav;
?&gt;
  </ul>

  <p class="button"><a href="/logout/">Log out</a></p>
  </div>
&lt;?php else : ?&gt;

<h2><span>Join GBOB</span></h2>
<div class="sidebaritem">
  <p class="intro">Sign up for free</p>
  <p class="button"><a href="/register/">GO!</a></p>
</div>

<h2><span>Log in</span></h2>
<div class="sidebaritem">
  &lt;form id="loginform" method="post" action="/login/submit"&gt;
    <fieldset>
      <label for="l_username">E-mail</label>
      &lt;input type="text" name="username" id="l_username" value=""&gt;
      <label for="l_password">Password</label>
      &lt;input type="password" name="password" id="l_password" value=""&gt;
      &lt;input type="submit" class="submit" value="Log in"&gt;
      <p><a href="/password/" style="font-size:11px;">> Forgotten Password?</a></p>
      <p id="loginfeedback"></p>
    </fieldset>
  &lt;/form&gt;
</div>

&lt;?php endif; ?&gt;

&lt;?php
$data = array();
$this->load->view('includes/sidebar_sponsor', $data);
?&gt;

Continue on next post....
#2

[eluser]stevenazari[/eluser]
Page 2: login.php (found in a "controllers" folder)

Code:
&lt;?php

class Login extends Controller {

  function Login()
  {
    parent::Controller();
  }
  
  function index()
  {
    $data['page'] = 'login';
    $data['pagetitle'] = 'Log in';
    $this->load->view('gbob/index', $data);
  }

  // Normal form submit
  function submit()
  {
    // Shouldn't happen, but should be allowed?
    // Must be rewritten.
    die();
  }

  // AJAX form submit
  function check()
  {
    $check_username = $this->input->post('username');
    $check_password = md5($this->input->post('password'));
    $this->db->where('user_name', $check_username);
    $this->db->where('password', $check_password);
    $query = $this->db->get('user');

    if($query->num_rows() == 1)
    {
      $userdata = $query->row();

      if ($userdata->user_type == 1)
      {
        $this->db->where('user_id', $userdata->id);
        $query = $this->db->get('band');
        if ($query->num_rows() != 1)
        {
          // Error with user/band connection
          header('Location: /');
          die();
        }
        $band = $query->row();
        $band_id = $band->id;
        $status = 'loggedin';
      }
      elseif($userdata->user_type == 2)
      {
        $band_id = '9705';
        $status = 'loggedin';
      }
      elseif($userdata->user_type == 3)
      {
        $band_id = '';
        $status = 'admin';
      }

      if ($userdata->active == 1)
      {
        $sessdata = array(
          'userid'      => $userdata->id,
          'bandid'      => $band_id,
/*
          'firstname'   => $userdata->first_name,
          'name'        => $userdata->first_name . ' ' . $userdata->last_name,
*/
          'username'    => $check_username,
          'usertype'    => $userdata->user_type,
          'logged_in'   => TRUE
        );

        $this->session->set_userdata($sessdata);
        print($status);
      }
      else
      {
        $this->session->sess_destroy();
        print('error');
      }
    }
    else
    {
      $this->session->sess_destroy();
      print('error');
    }
  }
}

?&gt;

can someone help and tell me what I need to paste into the php pages outside of the code igniter directory? Im stumped.

regards
Steven




Theme © iAndrew 2016 - Forum software by © MyBB