Jump to content
InvisionCommunity.de - Der Deutsche Invision Community Support
Sign in to follow this  
Koly007

[[[Suche]]] 4images in v1.3

Recommended Posts

Hallo!

Es gibt zwar schon einige Threads zu diesem Thema hat mir aber leider nicht geholfen... kann mir bitte wer sagen welchen MOD ich einbauen muss dass man sich nur 1mal für forum und für 4images registrieren muss? ich habe derzeit noch keinen einzigen user bei 4images nur im forum, falls das was hilft...

Kurz: Wie kann ich 4images in v1.3 einbauen?

mfg

Koly

Share this post


Link to post

den patch findest im forum von 4images ... nicht wundern - rennt noch unter ipb 1.1 oder so, geht aber 100% auch unter 1.3

angenehm dabei - null anpassung des forums nötig, 4images lest einfach die user aus der ipb-tabelle aus, bleibt somit absolut unberührt.

der patch is auch einfach ... einfach drüber spielen über die orignaldateien der galerie.

nachteil - ein paar problemchen mit den usern in der galerie-admin.

z.b. hast dann leichte probleme, usergruppen in der galerie anzulegen.

Share this post


Link to post

ne, du mußt nur ganz normal das 4images instlalieren, den patch drauf haun, und in der config_global.php der galerie natürlich alles korrekt anpassen (pfade, tabellenpräfixe, usw.)

btw - wenn ich per icq nicht quasseln will, sollte 1 ablehnung eigendlich reichen.

ich klick nicht geren 7 mal oder noch öfters

folgendes hast du in der conf irgenwo eingetragen:

/home/www/

korrekt sollts lauten:

/home/www/web16/html/

oder umgekehrt, was weiß ich, wie der abs. pfad bei deinem hoster lautet

Edited by Ratman

Share this post


Link to post

hm.. finde es aber trotzdem nicht hier meine conf_global.php

wäre wieder supi wenn du mir helfen kannst..

mfg

Koly

Edited by Koly007

Share this post


Link to post

ne, vom forum brauchst du gar nix ändern

nur von der galerie

irgendwo dort hast wohl anstatt /home/www/web16/html/4images/ nur '/home/www/4images/ eingetragen.

und lösch deinen user und passwort in zukunft aus deinen angaben raus, wennst hier was rein kopierst.

oder willst, das 100 leute auf deinem server rumgurken?

Edited by Ratman

Share this post


Link to post

nehmen ma mal an, die datei heißt config_global.php

sieh die fehlermeldung auf deiner seite:

Warning: main(): open_basedir restriction in effect. File(/home/www/forums/conf_global.php) is not within the allowed path(s): (/home/www/web16/)

wenn ich nicht ganz schräg liege, hast du in der config (oder einem file aus den patchdateien) der GALERIE einen verweis auf auf die config des forums zu legen.

wo die angabe jetzt genau liegt, weiß ich ned auswendig, steht aber sicher in der anleitung zum patch und sicher in der anleitung zur galerie.

ich kann dir derzeit bei mir nicht nachschaun, weil mein eigener server sein netzteil verraucht hat, und wir erst am dienstag wieder alles zum laufen bringen werden - mußt also ein bissi selber suchen ...

Share this post


Link to post

also ich muss da einige datein beim 4images hochladen/ersetzen und diese datei anpassen:

<?php

/**************************************************************************

 *                                                                        *

 *    4images - A Web Based Image Gallery Management System               *

 *    ----------------------------------------------------------------    *

 *                                                                        *

 *             File: sessions.php                                         *

 *        Copyright: (C) 2002 Jan Sorgalla                                *

 *            Email: jan@4homepages.de                                    *

 *              Web: http://www.4homepages.de                             *

 *    Scriptversion: 1.7                                                  *

 *                                                                        *

 *    Never released without support from: Nicky (http://www.nicky.net)   *

 *                                                                        *

 **************************************************************************

 *                                                                        *

 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *

 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *

 *    ---------------------------------------------------------------     *

 *    This script is NOT freeware! Please read the Copyright Notice       *

 *    (Licence.txt) for further information.                              *

 *                                                                        *

 *************************************************************************/


/* This script is for use with IBF 1.1 Only */


if (!defined('ROOT_PATH')) {

  die("Security violation");

}


//-----------------------------------------------------

//--- Start Configuration -----------------------------

//-----------------------------------------------------


// Set here the path to your IBF forum. WITH trailing slash!

$ibf_path = "/home/www/forums/";

include($ibf_path.'conf_global.php');


// Set here the URL to your IBF forum. WITH trailing slash!

$url_app = "http://www.yoursite.com/forums/";


// Set here different URL's to your Invisionboard forum.

// Normally no need to change.

$url_register      = $url_app."index.php?act=Reg&CODE=00";

$url_lost_password = $url_app."index.php?act=Reg&CODE=10";

$url_control_panel = $url_app."index.php?act=UserCP&CODE=00";

$url_mailform      = $url_app."index.php?act=Mail&CODE=00&MID={user_id}";

$url_show_profile  = $url_app."index.php?act=Profile&CODE=03&MID={user_id}";

$url_login         = $url_app."index.php?act=Login&CODE=00";

$url_logout        = $url_app."index.php?act=Login&CODE=03";


// Define here the name of the session. Default of IBF is "s".

define('SESSION_NAME', 's');


// Set here the corresponding database fields of the user table.

// If there is no corresponding field in the new user table, 

// leave the value blank. Normally no need to change.

$user_table_fields = array(

  "user_id" => "id",

  "user_level" => "mgroup",

  "user_name" => "name",

  "user_password" => "password",

  "user_email" => "email",

  "user_showemail" => "hide_email",

  "user_allowemails" => "email_full",

  "user_invisible" => "",

  "user_joindate" => "joined",

  "user_activationkey" => "",

  "user_lastaction" => "last_activity",

  "user_location" => "location",

  "user_lastvisit" => "last_visit",

  "user_comments" => "",

  "user_homepage" => "website",

  "user_icq" => "icq_number"

);


//-----------------------------------------------------

//--- End Configuration -------------------------------

//-----------------------------------------------------


define('USER_INTEGRATION', 'INVISIONBOARD');


function get_user_table_field($add, $user_field) {

  global $user_table_fields;

  return (!empty($user_table_fields[$user_field])) ? $add.$user_table_fields[$user_field] : "";

}


class Session {


  var $session_id;

  var $user_ip;

  var $user_location;

  var $current_time;

  var $session_timeout;

  var $mode = "get";

  var $session_info = array();

  var $user_info = array();


  function Session() {

    global $config, $INFO;

    $this->session_timeout = $INFO['session_expiration'] = $INFO['session_expiration'] ? (time() - $INFO['session_expiration']) : (time() - 3600);

    $this->user_ip = $this->get_user_ip();

    $this->user_location = $this->get_user_location();

    $this->current_time = time();

    $this->demand_session();

  }


  function set_cookie_data($name, $value = "", $permanent = 1) {

    if ($permanent == 1)

    {

      $cookie_expire = time() + 60*60*24*365;

    }

    $cookie_name = COOKIE_NAME.$name;

    setcookie($cookie_name, $value, $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);

  }


  function read_cookie_data($name) {

    global $HTTP_COOKIE_VARS;

    $cookie_name = COOKIE_NAME.$name;

    if (isset($HTTP_COOKIE_VARS[$cookie_name]))

	{

  return urldecode($HTTP_COOKIE_VARS[$cookie_name]);

	}

	else

	{

  return FALSE;

	}

  }


    function get_session_id($session_id="") {

        global $DB, $INFO, $std;

        

        $result = array();

        

        $query = "";

        

        $session_id = preg_replace("/([^a-zA-Z0-9])/", "", $session_id);

        

        if ( !empty($session_id) )

        {

 	 if ($INFO['match_browser'] == 1)

 	 {

    $query = " AND browser='".$this->user_agent."'";

 	 }

    

 	 $DB->query("SELECT id, member_id, running_time, location FROM ibf_sessions WHERE id='".$session_id."' and ip_address='".$this->ip_address."'".$query);

 	 

 	 if ($DB->get_num_rows() != 1)

 	 {

    // Either there is no session, or we have more than one session..

    $this->session_dead_id   = $session_id;

    $this->session_id        = 0;

          $this->session_user_id   = 0;

          return;

 	 }

 	 else

 	 {

    $result = $DB->fetch_row();

    

    if ($result['id'] == "")

    {

   	 $this->session_dead_id   = $session_id;

   	 $this->session_id        = 0;

   	 $this->user_id           = 0;

   	 unset($result);

   	 return;

    }

    else

    {

   	 $this->session_id        = $result['id'];

   	 $this->user_id           = $result['member_id'];

   	 $this->last_click        = $result['running_time'];

         	 $this->location          = $result['location'];

         	 unset($result);

   	 return;

    }

 	 }

  }

    }


  function demand_session() {

    $this->get_session_id();

    if (!$this->load_session_info()) {

      $this->delete_old_sessions();

      $user_id = ($this->read_cookie_data("member_id")) ? $this->read_cookie_data("member_id") : GUEST;

      $this->start_session($user_id);

    }

    else {

      $this->user_info = $this->load_user_info($this->session_info['member_id']);

      $update_cutoff = ($this->user_info['user_id'] != GUEST) ? $this->current_time - $this->user_info['user_lastaction'] : $this->current_time - $this->session_info['lastactivity'];

      if ($update_cutoff > 60) {

        $this->update_session();

        $this->delete_old_sessions();

      }

    }

  }


  function start_session($user_id = GUEST, $login_process = 0) {

    global $site_db, $INFO;

    

    $this->user_info = $this->load_user_info($user_id);

    if ($this->user_info['user_id'] != GUEST && !$login_process) {

      if ($this->read_cookie_data("pass_hash") == $this->user_info['user_password'] && $this->user_info['user_level'] > USER_AWAITING) {

        $this->set_cookie_data("pass_hash", $this->user_info['user_password']);

      }

      else {

        $this->set_cookie_data("pass_hash", "", 0);

        $this->user_info = $this->load_user_info(GUEST);

      }

    }

    $this->session_id = $this->generate_session_id();


    if ($this->member['id'] = '0') {

        echo "member 0";

        $sql = "INSERT INTO ".SESSIONS_TABLE." 

                (id, member_name, member_id, ip_address, browser, running_time, location, login_type, member_group) 

                VALUES ('".$this->session_id."', '', '0', '".$this->ip_address."', '".$this->user_agent."', '".$this->time_now."',

                ',,', '0', '".$INFO['guest_group']."')";

    } else {

        $sql = "INSERT INTO ".SESSIONS_TABLE." 

                (id, member_name, member_id, ip_address, browser, running_time, location, login_type, member_group) 

                VALUES ('".$this->session_id."', '".$this->member['name']."', '".$this->member['id']."', '".$this->ip_address."', '".$this->user_agent."', '".$this->time_now."',

                ',,', '".$ibforums->input['Privacy']."', '".$this->member['mgroup']."')";

    }

    

    $site_db->query($sql);

    $this->session_info['session_user_id'] = $this->user_info['user_id'];

    $this->session_info['session_lastaction'] = $this->current_time;

    $this->session_info['session_location'] = $this->user_location;

    $this->session_info['session_ip'] = $this->user_ip;


    if ($this->user_info['user_id'] != GUEST) {

      $sql = "UPDATE ".USERS_TABLE." 

              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time 

              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];

      $site_db->query($sql);

    }

    $this->set_cookie_data("id", $this->session_id, 0);

//    $this->set_cookie_data("lastvisit", $this->user_info['user_lastvisit'];

    $this->set_cookie_data("member_id", $this->user_info['user_id']);

    return true;

  }


  function login($user_name = "", $user_password = "", $auto_login = 0, $set_auto_login = 1) {

    global $url_login;

    header("Location: $url_login");

  }


  function logout($user_id = GUEST) {

    global $url_logout;

    header("Location: $url_logout");

  }


  function delete_old_sessions() {

    global $site_db;

    $expiry_time = $this->current_time - $this->session_timeout;

    $sql = "DELETE FROM ".SESSIONS_TABLE." 

            WHERE ip_address='".$ibforums->input['IP_ADDRESS']."'";


    $site_db->query($sql);


    $sql = "SELECT id 

            FROM ".SESSIONS_TABLE;

    $result = $site_db->query($sql);

    if ($result) {

      $session_ids_sql = "";

      while ($row = $site_db->fetch_array($result)) {

        $session_ids_sql .= (($session_ids_sql != "") ? ", " : "") . "'".$row['id']."'";

      }

    }

    if (!empty($session_ids_sql)) {

      $sql = "DELETE FROM ".SESSIONVARS_TABLE." 

              WHERE session_id NOT IN ($session_ids_sql)";

      $site_db->query($sql);

    }

    return true;

  }


  function update_session() {

    global $site_db;

    $sql = "UPDATE ibf_sessions SET " .

            "member_name='" .$this->member['name']     ."', ".

            "member_id='"   .$this->member['id']       ."', ".

            "member_group='".$this->member['mgroup']   ."', ";


    $site_db->query($sql);

    if ($this->user_info['user_id'] != GUEST) {

      $sql = "UPDATE ".USERS_TABLE." 

              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time 

              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];

      $site_db->query($sql);

    }

    return;

  }


  function generate_session_id() {

    global $site_db;

    $sid = md5(uniqid(microtime()));

    $i = 0;

    while ($i == 0) {

      $sql = "SELECT id 

              FROM ".SESSIONS_TABLE." 

              WHERE id = '$sid'";

      if ($site_db->is_empty($sql)) {

        $i = 1;

      }

      else {

        $i = 0;

        $sid = md5(uniqid(microtime()));

      }

    }

    return $sid;

  }


  function return_session_info() {

    return $this->session_info;

  }


  function return_user_info() {

    return $this->user_info;

  }

  

  function freeze() {

    return;

  }


  function load_session_info() {

    global $site_db;

    if (!$this->session_id) {

      return false;

    }

    $this->session_info = array();

    $sql = "SELECT id, ip_address, member_id 

            FROM ".SESSIONS_TABLE." 

            WHERE id = '$this->session_id' 

            AND ip_address = '$this->user_ip'";

    $this->session_info = $site_db->query_firstrow($sql);

    if (!isset($this->session_info['member_id'])) {

      return false;

    }

    else {

      $sql = "SELECT sessionvars_name, sessionvars_value 

              FROM ".SESSIONVARS_TABLE." 

              WHERE session_id = '$this->session_id'";

      $result = $site_db->query($sql);

      while ($row = $site_db->fetch_array($result)) {

        $this->session_info[$row['sessionvars_name']] = $row['sessionvars_value'];

      }

      return $this->session_info;

    }

  }


  function load_user_info($user_id = GUEST) {

    global $site_db, $user_table_fields;


    if ($user_id != GUEST) {

      $sql = "SELECT u.*, l.*

              FROM ".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l 

              WHERE ".get_user_table_field("u.", "user_id")." = $user_id AND l.user_id = ".get_user_table_field("u.", "user_id");

      $user_info = $site_db->query_firstrow($sql);

      if (!$user_info) {

        $sql = "SELECT *

                FROM ".USERS_TABLE." 

                WHERE ".get_user_table_field("", "user_id")." = $user_id";

        $user_info = $site_db->query_firstrow($sql);

        if ($user_info) {

          $lightbox_id = get_random_key(LIGHTBOXES_TABLE, "lightbox_id");

          $sql = "INSERT INTO ".LIGHTBOXES_TABLE." 

                  (lightbox_id, user_id, lightbox_lastaction, lightbox_image_ids) 

                  VALUES 

                  ('$lightbox_id', ".$user_info[$user_table_fields['user_id']].", $this->current_time, '')";

          $site_db->query($sql);

          $user_info['lightbox_lastaction'] = $this->current_time;

          $user_info['lightbox_image_ids'] = "";

        }

      }

    }

    if (empty($user_info[$user_table_fields['user_id']])) {

      $user_info = array();

      $user_info['user_id'] = GUEST;

      $user_info['user_level'] = GUEST;

      $user_info['user_lastaction'] = $this->current_time;

//      $user_info['user_lastvisit'] = ($this->read_cookie_data("lastvisit")) ? $this->read_cookie_data("lastvisit") : $this->current_time;

    }

    foreach ($user_table_fields as $key => $val) {

      if (isset($user_info[$val])) {

        $user_info[$key] = $user_info[$val];

      }

      elseif (!isset($user_info[$key])) {

        $user_info[$key] = "";

      }

    }

    return $user_info;

  }


  function set_session_var($var_name, $value) {

    global $site_db;

    $sql = "SELECT session_id 

            FROM ".SESSIONVARS_TABLE." 

            WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

    if ($site_db->is_empty($sql)) {

      $sql = "INSERT INTO ".SESSIONVARS_TABLE." 

              (session_id, sessionvars_name, sessionvars_value) 

              VALUES 

              ('$this->session_id', '$var_name', '$value')";

      $site_db->query($sql);

    }

    else {

      $sql = "UPDATE ".SESSIONVARS_TABLE." 

              SET sessionvars_value = '$value' 

              WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

      $site_db->query($sql);

    }

    $this->session_info[$var_name] = $value;

    return true;

  }


  function get_session_var($var_name) {

    global $site_db;

    if (isset($this->session_info[$var_name])) {

      return $this->session_info[$var_name];

    }

    else {

      $sql = "SELECT sessionvars_value 

              FROM ".SESSIONVARS_TABLE." 

              WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

      $value = $site_db->query_firstrow($sql);

      if ($value) {

        $this->session_info[$var_name] = $value['sessionvars_value'];

        return $value['sessionvars_value'];

      }

      else {

        return "";

      }

    }

  }


  function drop_session_var($var_name) {

    global $site_db;

    $sql = "DELETE FROM ".SESSIONVARS_TABLE." 

            WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

    return ($site_db->query($sql)) ? 1 : 0;

  }


  function get_user_ip() {

    global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;

    $ip = (!empty($HTTP_SERVER_VARS['REMOTE_ADDR'])) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ((!empty($HTTP_ENV_VARS['REMOTE_ADDR'])) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv("REMOTE_ADDR"));

    //$ip = preg_replace("/[^\.0-9]+/", "", $ip);

    return substr($ip, 0, 50);

  }


  function get_user_location() {

    global $self_url;

    return (defined("IN_CP")) ? "Control Panel" : preg_replace(array("/([?|&])action=[^?|&]*/", "/([?|&])mode=[^?|&]*/", "/([?|&])phpinfo=[^?|&]*/", "/([?|&])printstats=[^?|&]*/", "/[?|&]".URL_ID."=[^?|&]*/", "/[?|&]l=[^?|&]*/", "/[&?]+$/"), array("", "", "", "", "", "", ""), addslashes($self_url));

  }


  function url($url, $amp = "&amp;") {

    global $l;

    $dummy_array = explode("#", $url);

    $url = $dummy_array[0];


    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {

      $url .= preg_match("/\?/", $url) ? "$amp" : "?";

      $url .= SESSION_NAME."=".$this->session_id;

    }


    if (!empty($l)) {

      $url .= preg_match("/\?/", $url) ? "$amp" : "?";

      $url .= "l=".$l;

    }


    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";

    return $url;

  }

} //end of class


//-----------------------------------------------------

//--- Start Session -----------------------------------

//-----------------------------------------------------

define('COOKIE_NAME', "{$INFO['cookie_id']}"); 

define('COOKIE_PATH', "{$INFO['cookie_path']}"); 

define('COOKIE_DOMAIN', "{$INFO['cookie_domain']}"); 

$secure = (isset($SERVER_PORT) && $SERVER_PORT == "443") ? 1 : 0; 

define('COOKIE_SECURE', $secure);


//Start Session

$site_sess = new Session();


// Get Userinfo

$session_info = $site_sess->return_session_info();

$user_info = $site_sess->return_user_info();


//-----------------------------------------------------

//--- Get User Caches ---------------------------------

//-----------------------------------------------------

$num_total_online = 0;

$num_visible_online = 0;

$num_invisible_online = 0;

$num_registered_online = 0;

$num_guests_online = 0;

$user_online_list = "";

$prev_user_ids = array();

$prev_session_ips = array();


if (defined("GET_USER_ONLINE") && ($config['display_whosonline'] == 1 || $user_info['user_level'] == ADMIN)) {

  if (!isset($cookietimeout)) {

    $cookietimeout = 300;

  }

  $time_out = time() - $cookietimeout;

  $sql = "SELECT s.member_id, s.running_time, s.ip_address".get_user_table_field(", u.", "user_id").get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_invisible")." 

   FROM ".SESSIONS_TABLE." s 

   LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = s.member_id) 

   WHERE s.running_time >= $time_out 

   ORDER BY ".get_user_table_field("u.", "user_id")." ASC, s.ip_address ASC";

  $result = $site_db->query($sql);

  while ($row = $site_db->fetch_array($result)) {

    if ($row['member_id'] != GUEST && isset($row[$user_table_fields['user_name']])) {

      if (!isset($prev_user_ids[$row['member_id']])) {

        $is_invisible = (isset($row[$user_table_fields['user_invisible']]) && $row[$user_table_fields['user_invisible']] == 1) ? 1 : 0;

        $invisibleuser = ($is_invisible) ? "*" : "";

        $username = (isset($row[$user_table_fields['user_level']]) && $row[$user_table_fields['user_level']] == ADMIN && $config['highlight_admin'] == 1) ? sprintf("<b>%s</b>", $row[$user_table_fields['user_name']]) : $row[$user_table_fields['user_name']];

        if (!$is_invisible || $user_info['user_level'] == ADMIN) {

          $user_online_list .= ($user_online_list != "") ? ", " : "";

          $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $row['member_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$row['member_id'];

          $user_online_list .= "<a href=\"".$site_sess->url($user_profile_link)."\">".$username."</a>".$invisibleuser;

        }

        (!$is_invisible) ? $num_visible_online++ : $num_invisible_online++;

        $num_registered_online++;

      }

      $prev_user_ids[$row['member_id']] = 1;

    }

    else {

      if (!isset($prev_session_ips[$row['ip_address']])) {

        $num_guests_online++;

      }

    }

    $prev_session_ips[$row['ip_address']] = 1;

  }

  $num_total_online = $num_registered_online + $num_guests_online;


  $site_template->register_vars(array(

    "num_total_online" => $num_total_online,

    "num_invisible_online" => $num_invisible_online,

    "num_registered_online" => $num_registered_online,

    "num_guests_online" => $num_guests_online,

    "user_online_list" => $user_online_list

  ));

  $whos_online = $site_template->parse_template("whos_online");

  $site_template->register_vars("whos_online", $whos_online);

  unset($whos_online);

  unset($prev_user_ids);

  unset($prev_session_ips);

}

?>

was muss ich da daran ändern...?

mfg

Koly

Share this post


Link to post

da hast is ja schon - ziemlich am anfang:

// Set here the path to your IBF forum. WITH trailing slash!

$ibf_path = "/home/www/forums/";

sollte wohl $ibf_path = "/home/www/web16/forums/"; heißen

Share this post


Link to post

aja

glei drunter hast:

// Set here the URL to your IBF forum. WITH trailing slash!

$url_app = "http://www.yoursite.com/forums/";

solltest vielleicht auch anpassen *g*

Share this post


Link to post

ok sorry.. schon wieder langer text hier nochmal meine session.php:

<?php

/**************************************************************************

 *                                                                        *

 *    4images - A Web Based Image Gallery Management System               *

 *    ----------------------------------------------------------------    *

 *                                                                        *

 *             File: sessions.php                                         *

 *        Copyright: (C) 2002 Jan Sorgalla                                *

 *            Email: jan@4homepages.de                                    *

 *              Web: http://www.4homepages.de                             *

 *    Scriptversion: 1.7                                                  *

 *                                                                        *

 *    Never released without support from: Nicky (http://www.nicky.net)   *

 *                                                                        *

 **************************************************************************

 *                                                                        *

 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *

 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *

 *    ---------------------------------------------------------------     *

 *    This script is NOT freeware! Please read the Copyright Notice       *

 *    (Licence.txt) for further information.                              *

 *                                                                        *

 *************************************************************************/


/* This script is for use with IBF 1.1 Only */


if (!defined('ROOT_PATH')) {

  die("Security violation");

}


//-----------------------------------------------------

//--- Start Configuration -----------------------------

//-----------------------------------------------------


// Set here the path to your IBF forum. WITH trailing slash!

$ibf_path = "/home/www/web16/forum/";

include($ibf_path.'conf_global.php');


// Set here the URL to your IBF forum. WITH trailing slash!

$url_app = "http://cyber-maniac.koksa.org/forum/";


// Set here different URL's to your Invisionboard forum.

// Normally no need to change.

$url_register      = $url_app."index.php?act=Reg&CODE=00";

$url_lost_password = $url_app."index.php?act=Reg&CODE=10";

$url_control_panel = $url_app."index.php?act=UserCP&CODE=00";

$url_mailform      = $url_app."index.php?act=Mail&CODE=00&MID={user_id}";

$url_show_profile  = $url_app."index.php?act=Profile&CODE=03&MID={user_id}";

$url_login         = $url_app."index.php?act=Login&CODE=00";

$url_logout        = $url_app."index.php?act=Login&CODE=03";


// Define here the name of the session. Default of IBF is "s".

define('SESSION_NAME', 's');


// Set here the corresponding database fields of the user table.

// If there is no corresponding field in the new user table, 

// leave the value blank. Normally no need to change.

$user_table_fields = array(

  "user_id" => "id",

  "user_level" => "mgroup",

  "user_name" => "name",

  "user_password" => "password",

  "user_email" => "email",

  "user_showemail" => "hide_email",

  "user_allowemails" => "email_full",

  "user_invisible" => "",

  "user_joindate" => "joined",

  "user_activationkey" => "",

  "user_lastaction" => "last_activity",

  "user_location" => "location",

  "user_lastvisit" => "last_visit",

  "user_comments" => "",

  "user_homepage" => "website",

  "user_icq" => "icq_number"

);


//-----------------------------------------------------

//--- End Configuration -------------------------------

//-----------------------------------------------------


define('USER_INTEGRATION', 'INVISIONBOARD');


function get_user_table_field($add, $user_field) {

  global $user_table_fields;

  return (!empty($user_table_fields[$user_field])) ? $add.$user_table_fields[$user_field] : "";

}


class Session {


  var $session_id;

  var $user_ip;

  var $user_location;

  var $current_time;

  var $session_timeout;

  var $mode = "get";

  var $session_info = array();

  var $user_info = array();


  function Session() {

    global $config, $INFO;

    $this->session_timeout = $INFO['session_expiration'] = $INFO['session_expiration'] ? (time() - $INFO['session_expiration']) : (time() - 3600);

    $this->user_ip = $this->get_user_ip();

    $this->user_location = $this->get_user_location();

    $this->current_time = time();

    $this->demand_session();

  }


  function set_cookie_data($name, $value = "", $permanent = 1) {

    if ($permanent == 1)

    {

      $cookie_expire = time() + 60*60*24*365;

    }

    $cookie_name = COOKIE_NAME.$name;

    setcookie($cookie_name, $value, $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);

  }


  function read_cookie_data($name) {

    global $HTTP_COOKIE_VARS;

    $cookie_name = COOKIE_NAME.$name;

    if (isset($HTTP_COOKIE_VARS[$cookie_name]))

	{

  return urldecode($HTTP_COOKIE_VARS[$cookie_name]);

	}

	else

	{

  return FALSE;

	}

  }


    function get_session_id($session_id="") {

        global $DB, $INFO, $std;

        

        $result = array();

        

        $query = "";

        

        $session_id = preg_replace("/([^a-zA-Z0-9])/", "", $session_id);

        

        if ( !empty($session_id) )

        {

 	 if ($INFO['match_browser'] == 1)

 	 {

    $query = " AND browser='".$this->user_agent."'";

 	 }

    

 	 $DB->query("SELECT id, member_id, running_time, location FROM ibf_sessions WHERE id='".$session_id."' and ip_address='".$this->ip_address."'".$query);

 	 

 	 if ($DB->get_num_rows() != 1)

 	 {

    // Either there is no session, or we have more than one session..

    $this->session_dead_id   = $session_id;

    $this->session_id        = 0;

          $this->session_user_id   = 0;

          return;

 	 }

 	 else

 	 {

    $result = $DB->fetch_row();

    

    if ($result['id'] == "")

    {

   	 $this->session_dead_id   = $session_id;

   	 $this->session_id        = 0;

   	 $this->user_id           = 0;

   	 unset($result);

   	 return;

    }

    else

    {

   	 $this->session_id        = $result['id'];

   	 $this->user_id           = $result['member_id'];

   	 $this->last_click        = $result['running_time'];

         	 $this->location          = $result['location'];

         	 unset($result);

   	 return;

    }

 	 }

  }

    }


  function demand_session() {

    $this->get_session_id();

    if (!$this->load_session_info()) {

      $this->delete_old_sessions();

      $user_id = ($this->read_cookie_data("member_id")) ? $this->read_cookie_data("member_id") : GUEST;

      $this->start_session($user_id);

    }

    else {

      $this->user_info = $this->load_user_info($this->session_info['member_id']);

      $update_cutoff = ($this->user_info['user_id'] != GUEST) ? $this->current_time - $this->user_info['user_lastaction'] : $this->current_time - $this->session_info['lastactivity'];

      if ($update_cutoff > 60) {

        $this->update_session();

        $this->delete_old_sessions();

      }

    }

  }


  function start_session($user_id = GUEST, $login_process = 0) {

    global $site_db, $INFO;

    

    $this->user_info = $this->load_user_info($user_id);

    if ($this->user_info['user_id'] != GUEST && !$login_process) {

      if ($this->read_cookie_data("pass_hash") == $this->user_info['user_password'] && $this->user_info['user_level'] > USER_AWAITING) {

        $this->set_cookie_data("pass_hash", $this->user_info['user_password']);

      }

      else {

        $this->set_cookie_data("pass_hash", "", 0);

        $this->user_info = $this->load_user_info(GUEST);

      }

    }

    $this->session_id = $this->generate_session_id();


    if ($this->member['id'] = '0') {

        echo "member 0";

        $sql = "INSERT INTO ".SESSIONS_TABLE." 

                (id, member_name, member_id, ip_address, browser, running_time, location, login_type, member_group) 

                VALUES ('".$this->session_id."', '', '0', '".$this->ip_address."', '".$this->user_agent."', '".$this->time_now."',

                ',,', '0', '".$INFO['guest_group']."')";

    } else {

        $sql = "INSERT INTO ".SESSIONS_TABLE." 

                (id, member_name, member_id, ip_address, browser, running_time, location, login_type, member_group) 

                VALUES ('".$this->session_id."', '".$this->member['name']."', '".$this->member['id']."', '".$this->ip_address."', '".$this->user_agent."', '".$this->time_now."',

                ',,', '".$ibforums->input['Privacy']."', '".$this->member['mgroup']."')";

    }

    

    $site_db->query($sql);

    $this->session_info['session_user_id'] = $this->user_info['user_id'];

    $this->session_info['session_lastaction'] = $this->current_time;

    $this->session_info['session_location'] = $this->user_location;

    $this->session_info['session_ip'] = $this->user_ip;


    if ($this->user_info['user_id'] != GUEST) {

      $sql = "UPDATE ".USERS_TABLE." 

              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time 

              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];

      $site_db->query($sql);

    }

    $this->set_cookie_data("id", $this->session_id, 0);

//    $this->set_cookie_data("lastvisit", $this->user_info['user_lastvisit'];

    $this->set_cookie_data("member_id", $this->user_info['user_id']);

    return true;

  }


  function login($user_name = "", $user_password = "", $auto_login = 0, $set_auto_login = 1) {

    global $url_login;

    header("Location: $url_login");

  }


  function logout($user_id = GUEST) {

    global $url_logout;

    header("Location: $url_logout");

  }


  function delete_old_sessions() {

    global $site_db;

    $expiry_time = $this->current_time - $this->session_timeout;

    $sql = "DELETE FROM ".SESSIONS_TABLE." 

            WHERE ip_address='".$ibforums->input['IP_ADDRESS']."'";


    $site_db->query($sql);


    $sql = "SELECT id 

            FROM ".SESSIONS_TABLE;

    $result = $site_db->query($sql);

    if ($result) {

      $session_ids_sql = "";

      while ($row = $site_db->fetch_array($result)) {

        $session_ids_sql .= (($session_ids_sql != "") ? ", " : "") . "'".$row['id']."'";

      }

    }

    if (!empty($session_ids_sql)) {

      $sql = "DELETE FROM ".SESSIONVARS_TABLE." 

              WHERE session_id NOT IN ($session_ids_sql)";

      $site_db->query($sql);

    }

    return true;

  }


  function update_session() {

    global $site_db;

    $sql = "UPDATE ibf_sessions SET " .

            "member_name='" .$this->member['name']     ."', ".

            "member_id='"   .$this->member['id']       ."', ".

            "member_group='".$this->member['mgroup']   ."', ";


    $site_db->query($sql);

    if ($this->user_info['user_id'] != GUEST) {

      $sql = "UPDATE ".USERS_TABLE." 

              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time 

              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];

      $site_db->query($sql);

    }

    return;

  }


  function generate_session_id() {

    global $site_db;

    $sid = md5(uniqid(microtime()));

    $i = 0;

    while ($i == 0) {

      $sql = "SELECT id 

              FROM ".SESSIONS_TABLE." 

              WHERE id = '$sid'";

      if ($site_db->is_empty($sql)) {

        $i = 1;

      }

      else {

        $i = 0;

        $sid = md5(uniqid(microtime()));

      }

    }

    return $sid;

  }


  function return_session_info() {

    return $this->session_info;

  }


  function return_user_info() {

    return $this->user_info;

  }

  

  function freeze() {

    return;

  }


  function load_session_info() {

    global $site_db;

    if (!$this->session_id) {

      return false;

    }

    $this->session_info = array();

    $sql = "SELECT id, ip_address, member_id 

            FROM ".SESSIONS_TABLE." 

            WHERE id = '$this->session_id' 

            AND ip_address = '$this->user_ip'";

    $this->session_info = $site_db->query_firstrow($sql);

    if (!isset($this->session_info['member_id'])) {

      return false;

    }

    else {

      $sql = "SELECT sessionvars_name, sessionvars_value 

              FROM ".SESSIONVARS_TABLE." 

              WHERE session_id = '$this->session_id'";

      $result = $site_db->query($sql);

      while ($row = $site_db->fetch_array($result)) {

        $this->session_info[$row['sessionvars_name']] = $row['sessionvars_value'];

      }

      return $this->session_info;

    }

  }


  function load_user_info($user_id = GUEST) {

    global $site_db, $user_table_fields;


    if ($user_id != GUEST) {

      $sql = "SELECT u.*, l.*

              FROM ".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l 

              WHERE ".get_user_table_field("u.", "user_id")." = $user_id AND l.user_id = ".get_user_table_field("u.", "user_id");

      $user_info = $site_db->query_firstrow($sql);

      if (!$user_info) {

        $sql = "SELECT *

                FROM ".USERS_TABLE." 

                WHERE ".get_user_table_field("", "user_id")." = $user_id";

        $user_info = $site_db->query_firstrow($sql);

        if ($user_info) {

          $lightbox_id = get_random_key(LIGHTBOXES_TABLE, "lightbox_id");

          $sql = "INSERT INTO ".LIGHTBOXES_TABLE." 

                  (lightbox_id, user_id, lightbox_lastaction, lightbox_image_ids) 

                  VALUES 

                  ('$lightbox_id', ".$user_info[$user_table_fields['user_id']].", $this->current_time, '')";

          $site_db->query($sql);

          $user_info['lightbox_lastaction'] = $this->current_time;

          $user_info['lightbox_image_ids'] = "";

        }

      }

    }

    if (empty($user_info[$user_table_fields['user_id']])) {

      $user_info = array();

      $user_info['user_id'] = GUEST;

      $user_info['user_level'] = GUEST;

      $user_info['user_lastaction'] = $this->current_time;

//      $user_info['user_lastvisit'] = ($this->read_cookie_data("lastvisit")) ? $this->read_cookie_data("lastvisit") : $this->current_time;

    }

    foreach ($user_table_fields as $key => $val) {

      if (isset($user_info[$val])) {

        $user_info[$key] = $user_info[$val];

      }

      elseif (!isset($user_info[$key])) {

        $user_info[$key] = "";

      }

    }

    return $user_info;

  }


  function set_session_var($var_name, $value) {

    global $site_db;

    $sql = "SELECT session_id 

            FROM ".SESSIONVARS_TABLE." 

            WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

    if ($site_db->is_empty($sql)) {

      $sql = "INSERT INTO ".SESSIONVARS_TABLE." 

              (session_id, sessionvars_name, sessionvars_value) 

              VALUES 

              ('$this->session_id', '$var_name', '$value')";

      $site_db->query($sql);

    }

    else {

      $sql = "UPDATE ".SESSIONVARS_TABLE." 

              SET sessionvars_value = '$value' 

              WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

      $site_db->query($sql);

    }

    $this->session_info[$var_name] = $value;

    return true;

  }


  function get_session_var($var_name) {

    global $site_db;

    if (isset($this->session_info[$var_name])) {

      return $this->session_info[$var_name];

    }

    else {

      $sql = "SELECT sessionvars_value 

              FROM ".SESSIONVARS_TABLE." 

              WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

      $value = $site_db->query_firstrow($sql);

      if ($value) {

        $this->session_info[$var_name] = $value['sessionvars_value'];

        return $value['sessionvars_value'];

      }

      else {

        return "";

      }

    }

  }


  function drop_session_var($var_name) {

    global $site_db;

    $sql = "DELETE FROM ".SESSIONVARS_TABLE." 

            WHERE sessionvars_name = '$var_name' AND session_id = '$this->session_id'";

    return ($site_db->query($sql)) ? 1 : 0;

  }


  function get_user_ip() {

    global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;

    $ip = (!empty($HTTP_SERVER_VARS['REMOTE_ADDR'])) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ((!empty($HTTP_ENV_VARS['REMOTE_ADDR'])) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv("REMOTE_ADDR"));

    //$ip = preg_replace("/[^\.0-9]+/", "", $ip);

    return substr($ip, 0, 50);

  }


  function get_user_location() {

    global $self_url;

    return (defined("IN_CP")) ? "Control Panel" : preg_replace(array("/([?|&])action=[^?|&]*/", "/([?|&])mode=[^?|&]*/", "/([?|&])phpinfo=[^?|&]*/", "/([?|&])printstats=[^?|&]*/", "/[?|&]".URL_ID."=[^?|&]*/", "/[?|&]l=[^?|&]*/", "/[&?]+$/"), array("", "", "", "", "", "", ""), addslashes($self_url));

  }


  function url($url, $amp = "&amp;") {

    global $l;

    $dummy_array = explode("#", $url);

    $url = $dummy_array[0];


    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {

      $url .= preg_match("/\?/", $url) ? "$amp" : "?";

      $url .= SESSION_NAME."=".$this->session_id;

    }


    if (!empty($l)) {

      $url .= preg_match("/\?/", $url) ? "$amp" : "?";

      $url .= "l=".$l;

    }


    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";

    return $url;

  }

} //end of class


//-----------------------------------------------------

//--- Start Session -----------------------------------

//-----------------------------------------------------

define('COOKIE_NAME', "{$INFO['cookie_id']}"); 

define('COOKIE_PATH', "{$INFO['cookie_path']}"); 

define('COOKIE_DOMAIN', "{$INFO['cookie_domain']}"); 

$secure = (isset($SERVER_PORT) && $SERVER_PORT == "443") ? 1 : 0; 

define('COOKIE_SECURE', $secure);


//Start Session

$site_sess = new Session();


// Get Userinfo

$session_info = $site_sess->return_session_info();

$user_info = $site_sess->return_user_info();


//-----------------------------------------------------

//--- Get User Caches ---------------------------------

//-----------------------------------------------------

$num_total_online = 0;

$num_visible_online = 0;

$num_invisible_online = 0;

$num_registered_online = 0;

$num_guests_online = 0;

$user_online_list = "";

$prev_user_ids = array();

$prev_session_ips = array();


if (defined("GET_USER_ONLINE") && ($config['display_whosonline'] == 1 || $user_info['user_level'] == ADMIN)) {

  if (!isset($cookietimeout)) {

    $cookietimeout = 300;

  }

  $time_out = time() - $cookietimeout;

  $sql = "SELECT s.member_id, s.running_time, s.ip_address".get_user_table_field(", u.", "user_id").get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_invisible")." 

   FROM ".SESSIONS_TABLE." s 

   LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = s.member_id) 

   WHERE s.running_time >= $time_out 

   ORDER BY ".get_user_table_field("u.", "user_id")." ASC, s.ip_address ASC";

  $result = $site_db->query($sql);

  while ($row = $site_db->fetch_array($result)) {

    if ($row['member_id'] != GUEST && isset($row[$user_table_fields['user_name']])) {

      if (!isset($prev_user_ids[$row['member_id']])) {

        $is_invisible = (isset($row[$user_table_fields['user_invisible']]) && $row[$user_table_fields['user_invisible']] == 1) ? 1 : 0;

        $invisibleuser = ($is_invisible) ? "*" : "";

        $username = (isset($row[$user_table_fields['user_level']]) && $row[$user_table_fields['user_level']] == ADMIN && $config['highlight_admin'] == 1) ? sprintf("<b>%s</b>", $row[$user_table_fields['user_name']]) : $row[$user_table_fields['user_name']];

        if (!$is_invisible || $user_info['user_level'] == ADMIN) {

          $user_online_list .= ($user_online_list != "") ? ", " : "";

          $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $row['member_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$row['member_id'];

          $user_online_list .= "<a href=\"".$site_sess->url($user_profile_link)."\">".$username."</a>".$invisibleuser;

        }

        (!$is_invisible) ? $num_visible_online++ : $num_invisible_online++;

        $num_registered_online++;

      }

      $prev_user_ids[$row['member_id']] = 1;

    }

    else {

      if (!isset($prev_session_ips[$row['ip_address']])) {

        $num_guests_online++;

      }

    }

    $prev_session_ips[$row['ip_address']] = 1;

  }

  $num_total_online = $num_registered_online + $num_guests_online;


  $site_template->register_vars(array(

    "num_total_online" => $num_total_online,

    "num_invisible_online" => $num_invisible_online,

    "num_registered_online" => $num_registered_online,

    "num_guests_online" => $num_guests_online,

    "user_online_list" => $user_online_list

  ));

  $whos_online = $site_template->parse_template("whos_online");

  $site_template->register_vars("whos_online", $whos_online);

  unset($whos_online);

  unset($prev_user_ids);

  unset($prev_session_ips);

}

?>

Share this post


Link to post

also

derzeit:

// Set here the path to your IBF forum. WITH trailing slash!

$ibf_path = "/home/www/web16/forum/";

ändern in:

// Set here the path to your IBF forum. WITH trailing slash!

$ibf_path = "/home/www/web16/html/forum/";

Share this post


Link to post

i see

der rest is n fehler mit deinen tables

wo der herkommt ... frag mich ned

hast die galerie korrekt installiert - heißen die präfixe auch so, wies wirklich heißen sollen?

kannst du ein bild testweise reinstellen in die gal?

Edited by Ratman

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×