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

Lo-Fi Version von "lofiversion1.1iDS Beta"

Recommended Posts

Wenn ich es richtig verstanden habe, ist das ja ein MOD der von 1.1 kommt und nochmal auf 1.3 gepusht wurde. Ansich ist er simpel und erfüllt seinen Zweck ( mobilesSurfen ) wunderbar. Aber ... ;)

Die Sortierung des Boards ist völlig gemischt. Das ist doch scheinbar nur ein Miniproblem/Bug ... Hat dazu jemand eine Idee ?

Danke für eure Hilfe !

@usa

<?php


/*

+--------------------------------------------------------------------------

|   Lo-Fi Version 1.1 iDS Beta

|   ========================================

|   by Matthew Mecham

|	by Shaun Harrison

|   (c) 2001 - 2003 [url="https://www.invisionpower.com/clients/index.php?app=nexus&module=promotion&section=referral&id=5636&direct=aHR0cDovL3d3dy5pbnZpc2lvbnBvd2VyLmNvbS8%3D"]Invision Power Services[/url]

|   http://www.invisionpower.com

|	http://www.layer04.com

|   ========================================

|   Web: http://www.layer04.com

+---------------------------------------------------------------------------

|

|   > LO-FI VERSION!

|   > Script written by Matt Mecham

|   > Date started: 11th March 2004

|   > Interesting fact: Wrote this while listening to the Stereophonic's

|   > 'Performance and Cocktails' CD. That was when they were good.

|   > Lo-fi feature took about 1.5 days to write. That's a lot of CD

|   > repeating...

|

|	> Lo-Fi Version 1.1 was re-written to work with 1.3.x

|	> It is possible this works with 1.2 but never tested it

|	> Took about 5-6 hours to re-write everyting

|	> IPB2.0 uses a ton of cache, where as, 1.3 does not

|	> I had to re-write everything into using SQL statement,

|	> I had this working with the new mysql driver,

|	> But I re-wrote all the queries from constructs and such

|	> Into straight simple queries so there was no un-needed files

|	> When you load this up into your version.

+--------------------------------------------------------------------------

*/


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

// USER CONFIGURABLE ELEMENTS

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


// Root path


define( 'ROOT_PATH', "../" );

define( 'LOFI_NAME', 'lofiversion' );


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

// NO USER EDITABLE SECTIONS BELOW

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


define ( 'IN_IPB', 1 );

define ( 'IN_DEV', 0 );


error_reporting  (E_ERROR | E_WARNING | E_PARSE);

set_magic_quotes_runtime(0);


//===========================================================================

// DEBUG CLASS

//===========================================================================


class Debug

{

    function startTimer()

    {

        global $starttime;

        $mtime = microtime ();

        $mtime = explode (' ', $mtime);

        $mtime = $mtime[1] + $mtime[0];

        $starttime = $mtime;

    }

    function endTimer()

    {

        global $starttime;

        $mtime = microtime ();

        $mtime = explode (' ', $mtime);

        $mtime = $mtime[1] + $mtime[0];

        $endtime = $mtime;

        $totaltime = round (($endtime - $starttime), 5);

        return $totaltime;

    }

}


//===========================================================================

// INFO CLASS

//===========================================================================


class info {


	var $member       = array();

	var $input        = array();

	var $session_id   = "";

	var $base_url     = "";

	var $vars         = "";

	var $lang_id      = "en";

	var $skin         = "";

	var $lang         = "";

	var $server_load  = 0;

	var $version      = "v1.3.1 iDS Final";

	var $lastclick    = "";

	var $location     = "";

	var $debug_html   = "";

	var $perm_id      = "";

	var $forum_read   = array();

	var $topic_cache  = "";

	var $session_type = "";

	var $skin_global  = "";

	var $display_max_topics = "";

	var $display_max_posts = "";


	var $scache = array();

	var $sfcache = array();

	var $sforum_cache = array(array());

	var $sforum_by_id = array();


    

	function info()

	{

  global $sess, $std, $DB, $INFO;

  

  $this->vars = &$INFO;

  

  $this->vars['AVATARS_URL']     = 'style_avatars';

  $this->vars['EMOTICONS_URL']   = 'style_emoticons/<#EMO_DIR#>';

  $this->vars['mime_img']        = 'style_images/<#IMG_DIR#>/folder_mime_types';


	}

}


//===========================================================================

// MAIN PROGRAM

//===========================================================================


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

// Import $INFO, now!

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


$INFO = array();


require ROOT_PATH."conf_global.php";


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

// The clocks a' tickin'

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

  

$Debug = new Debug;

$Debug->startTimer();


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

// Load the DB driver and such

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


$INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mysql' : $INFO['sql_driver'];


require ( ROOT_PATH."sources/Drivers/mySQL.php" );


$DB = new db_driver;


$DB->obj['sql_database']     = $INFO['sql_database'];

$DB->obj['sql_user']         = $INFO['sql_user'];

$DB->obj['sql_pass']         = $INFO['sql_pass'];

$DB->obj['sql_host']         = $INFO['sql_host'];

$DB->obj['sql_tbl_prefix']   = $INFO['sql_tbl_prefix'];

$DB->obj['use_shutdown']     = 0;

$DB->obj['debug']            = 0;


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

// Get a DB connection

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


$DB->connect();


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

// Wrap it all up in a nice easy to

// transport super class

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


$ibforums = new info();


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

// Require our global functions

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


require ROOT_PATH."sources/functions.php";


$std    = new FUNC;

$sess   = new session();


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

//  Set up our vars

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


$ibforums->input = $std->parse_incoming();



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

//  The rest :D

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


$ibforums->member = $sess->authorise();

$std->load_skin();


$ibforums->vars['display_max_topics'] = 40;

$ibforums->vars['display_max_posts']  = 20;




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

//  Initialize the forums

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


$ibforums->session_id = "";

$ibforums->base_url   = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext'].'?';



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

//  Do we have permission to view

//  the board?

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


if ($ibforums->member['g_view_board'] != 1)

{ 

	$std->boink_it( '../index.php' );

}


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

//  Is the board offline?

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


if ($ibforums->vars['board_offline'] == 1)

{

	if ($ibforums->member['g_access_offline'] != 1)

	{

  $std->boink_it( '../index.php' );

	}

}


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

//  Is log in enforced?

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


if ( (! $ibforums->member['id']) and ($ibforums->vars['force_login'] == 1) )

{

	$std->boink_it( '../index.php' );


}




//===========================================================================

// DO STUFF!

//===========================================================================


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

// Not index.php/ ? Redirect

// We do this so we can use relative

// links...

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


$main_string = $_SERVER['PHP_SELF'];



if ( ! strstr( $main_string, '/index.php/' ) ) {

	$std->boink_it( $ibforums->vars['board_url'].'/'.LOFI_NAME.'/index.php/' );

}


if ( strstr( $main_string, "/" ) ) {

	$main_string = str_replace( "/", "", strrchr( $main_string, "/" ) );

}


$main_string = str_replace(".html", "", $main_string );


$action = 'index';

$id    = 0;

$st    = 0;


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

// Pages?

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


if ( strstr( $main_string, "-" ) )

{

	list( $main, $start ) = explode( "-", $main_string );


	$main_string = $main;

	$st          = $start;

}


$st = intval($st);


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

// What we doing?

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



if ( strstr( $main_string, 't' ) ) {

	$action = 'topic';

	$id    = intval( str_replace( "t", "", $main_string ) );

} elseif ( strstr( $main_string, 'f' ) ) {

	$action = 'forum';

	$id    = intval( str_replace( "f", "", $main_string ) );

}


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

// Require 'skin'

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


require_once( './lofi_skin.php' );


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

// Do it!

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


$output = "";


switch ( $action ) {

	case 'forum':

  $ibforums->real_link = $ibforums->base_url.'showforum='.$id;

  $output = get_forum_page($id, $st);

  break;

	case 'topic':

  $ibforums->real_link = $ibforums->base_url.'showtopic='.$id;

  $output = get_topic_page($id, $st);

  break;

	default:

  $ibforums->real_link = $ibforums->base_url;

  $output = get_index_page();

  break;

}


print_it($output);



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

// Board index

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


function get_index_page()

{

	global $ibforums, $std, $DB, $forums, $LOFISKIN;


	return LOFISKIN_forums( _get_forums() );

}


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

// Forums index

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


function _can_view($perms) {

	if(($perms== '*') || (strstr($perms, '2'))) {

  return TRUE;

	} else {

  return FALSE;

	}

}


function _get_forum_data($id) {

	global $DB;


	$DB->query("SELECT * FROM `ibf_forums` WHERE `id` = '{$id}'");


	return $DB->fetch_row();

}


function get_forum_page($id, $st) {	global $ibforums, $std, $DB, $forums, $LOFISKIN, $navarray;


	$output = "";



	$forum_data = _get_forum_data($id);


	if (! _can_view($forum_data['read_perms']))

	{

  $std->boink_it( $ibforums->vars['board_url'].'/'.LOFI_NAME.'/index.php/' );

	} 


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

	// Nav array...

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


	$navarray = _get_nav_array($id);


	$ibforums->title = $forum_data['name'];


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

  // Show topics...

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

  

  $ibforums->pages = _get_pages($forum_data['topics'], $ibforums->vars['display_max_topics'], 'f'.$id );

  

  if ( ! $ibforums->member['g_other_topics'])

  {

 	 $query = " and starter_id=".$ibforums->member['id'];

  }

  

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

  // Topics...

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

  


  $result = $DB->query("SELECT * FROM `ibf_topics` WHERE `approved` = '1' AND `forum_id` = '{$id}' ORDER BY `pinned` DESC, `last_post` DESC LIMIT {$st}, {$ibforums->vars['display_max_topics']}");

  

  $num = mysql_num_rows($result);

  $cur = 0;


  while($cur <= $num) {

 	 $r = mysql_fetch_array($result);

 	 if($r) {

    if ($r['pinned']) {

   	 $r['_prefix'] = 'Pinned: ';

    } else {

   	 $r['_prefix'] = "";

    }

    

    if ($r['state'] == 'link') {

   	 $t_array = explode("&", $r['moved_to']);

   	 $r['tid']       = $t_array[0];

   	 $r['forum_id']  = $t_array[1];

   	 $r['title']     = $r['title'];

   	 $r['posts']     = '--';

   	 $r['_prefix']   = 'Moved: ';

    }

    

    

    $output .= LOFISKIN_topics_entry($r);

 	 }


 	 $cur++;

  }

  

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

  // Return..

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


  return LOFISKIN_topics($output);

}


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

// Topics index

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


function get_topic_page($id, $st) {

	global $ibforums, $std, $DB, $forums, $LOFISKIN, $navarray;


	$output = "";



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

	// Get post_parser

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


	require_once( ROOT_PATH."sources/lib/post_parser.php" );

	$parser = new post_parser();


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

	// get topic

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


	$DB->query("SELECT * FROM `ibf_topics` WHERE `tid` = '{$id}' AND `approved` = '1'");


	$topic = $DB->fetch_row();


	$forum_data = _get_forum_data($topic['forum_id']);



      

	if (!$topic['tid']) {

  $std->boink_it( $ibforums->vars['board_url'].'/'.LOFI_NAME.'/index.php/' );

	}



	if (! _can_view($forum_data['read_perms'])) {

  $std->boink_it( $ibforums->vars['board_url'].'/'.LOFI_NAME.'/index.php/' );

	}


	$ibforums->pages = _get_pages($topic['posts'], $ibforums->vars['display_max_posts'], 't'.$id);



	$ibforums->title = $topic['title'];


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

	// get posts...

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


	$DB->query("SELECT * FROM `ibf_posts` WHERE `topic_id` = '{$id}' AND `queued` != '1' ORDER BY `pid` LIMIT {$st}, {$ibforums->vars['display_max_posts']}");


	while( $r = $DB->fetch_row() )

	{


  $r['post_date'] = $std->get_date( $r['post_date'], 'LONG', 1 );

  

  $output .= LOFISKIN_posts_entry($r);

	}


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

	// Nav array...

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



	$navarray   = _get_nav_array( $topic['forum_id'] );


	return $output;


}


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

// Print it

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


function print_it($content, $title='')

{

	global $ibforums, $std, $DB, $forums, $LOFISKIN, $navarray;


	$fullurl   = $ibforums->vars['board_url'].'/'.LOFI_NAME.'/';


	$copyright = "Invision Power Board &copy; 2001-".date("Y")." <a href='http://www.invisionpower.com'>[url="https://www.invisionpower.com/clients/index.php?app=nexus&module=promotion&section=referral&id=5636&direct=aHR0cDovL3d3dy5pbnZpc2lvbnBvd2VyLmNvbS8%3D"]Invision Power Services[/url], Inc.</a>";

	$copyright .= "<br> Lo-Fi 1.1 iDS Beta, Originally written by Matt,<br> re-written by Shaun Harrison, <a href='http://www.layer04.com'>Layer 04.com</a>, for pre IPB2.0 versions.";


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

	// Nav

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


	$nav = "<a href='./'>".$ibforums->vars['board_name']."</a>";


	if ( count($navarray) )

	{

  $nav .= " &gt; " . implode( " &gt; ", $navarray );

	}


	$title = $ibforums->title ? $ibforums->vars['board_name'].' &gt; '.$ibforums->title : $ibforums->vars['board_name'];


	$pages = "";


	if ( $ibforums->pages )

	{

  $pages = LOFISKIN_pages( $ibforums->pages );

	}


	$output = str_replace( '<% TITLE %>'    , $title    , $LOFISKIN['wrapper'] );

	$output = str_replace( '<% CONTENT %>'  , $content  , $output );

	$output = str_replace( '<% FULL_URL %>' , $fullurl  , $output );

	$output = str_replace( '<% COPYRIGHT %>', $copyright, $output );

	$output = str_replace( '<% NAV %>'      , $nav      , $output );

	$output = str_replace( '<% LINK %>'     , $ibforums->real_link, $output );

	$output = str_replace( '<% LARGE_TITLE %>', $ibforums->title ? $ibforums->title : $ibforums->vars['board_name'], $output );

	$output = str_replace( '<% PAGES %>'     , $pages, $output );


	$output = str_replace( "<#IMG_DIR#>", $ibforums->skin['_imagedir'], $output );

	$output = str_replace( "<#EMO_DIR#>", $ibforums->skin['_emodir']  , $output );


	$output = str_replace( "style_emoticons/", $ibforums->vars['board_url']."/style_emoticons/", $output );

  

	print $output;

}







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

// Recursively get forums

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


function _get_forums() {

	global $DB;


	$result = $DB->query("SELECT * FROM `ibf_categories` WHERE `id` != '-1'");


	$num = mysql_num_rows($result);

	$cur = 0;


	while($cur <= $num) {

 	 $row = mysql_fetch_array($result);

 	 if($row['id'] != '') {

    $html_string .= LOFISKIN_forums_entry_first($row);

        

    $html_string = _get_children($html_string, "", $row['id'], "-1");


    $html_string .= LOFISKIN_forums_entry_end($depth_guide);

 	 }

 	 $cur++;

	}


	return $html_string;

}



function _get_children($html_string="", $depth_guide="", $category, $root) {

	global $DB;


	$result = $DB->query("SELECT * FROM `ibf_forums` WHERE `category` = '{$category}' AND `parent_id` = '{$root}' ORDER BY `position` ASC");


	$num = mysql_num_rows($result);

	$cur = 0;


	while($cur <= $num) {

  $forum_data = mysql_fetch_array($result);

  if($forum_data['id'] != '') {

 	 if(($forum_data['read_perms'] == '*') || (strstr($forum_data['read_perms'], '2'))) {

    $forum_data['total_posts'] = intval( $forum_data['topics'] + $forum_data['posts'] );

    $html_string .= LOFISKIN_forums_entry("", $forum_data);

    $html_string  = _get_sub_children($html_string, "", $category, $forum_data['id']);

 	 }

  }

  $cur++;

	}


	return $html_string;

}


function _get_sub_children($html_string="", $depth_guide="", $category, $root) {

	global $DB;


	$result = $DB->query("SELECT * FROM `ibf_forums` WHERE `category` = '{$category}' AND `parent_id` = '{$root}' ORDER BY `position` ASC");


	$num = mysql_num_rows($result);

	$cur = 0;


	$html_string .=  LOFISKIN_forums_entry_start($depth_guide);


	while($cur <= $num) {

  $forum_data = mysql_fetch_array($result);

  if($forum_data['id'] != '') {

 	 if(($forum_data['read_perms'] == '*') || (strstr($forum_data['read_perms'], '2'))) {

    $forum_data['total_posts'] = intval( $forum_data['topics'] + $forum_data['posts'] );

    $html_string .= LOFISKIN_forums_entry($depth_guide, $forum_data);

    $html_string  = _get_sub_children($html_string, "    ".$depth_guide, $category, $forum_data['id']);

 	 }

  }

  $cur++;

	}


	$html_string .= LOFISKIN_forums_entry_end($depth_guide);


	return $html_string;

}



function _get_nav_array($id) {

	global $ibforums, $DB, $LOFISKIN;


	$DB->query("SELECT * FROM `ibf_forums` WHERE `id` = '{$id}'");

	$fbyid = $DB->fetch_row();


	$navarray[] = "<a href='f{$id}.html'>{$fbyid['name']}</a>";


	$ids = _forums_get_parents( $id );


	if (is_array($ids) and count($ids) ) {

  foreach( $ids as $id ) {

 	 $DB->query("SELECT * FROM `ibf_forums` WHERE `id` = '{$id}'");

 	 $fbyid2 = $DB->fetch_row();

  

 	 $navarray[] = "<a href='f{$fbyid2['id']}.html'>{$fbyid2['name']}</a>";

  }

	}


	return array_reverse($navarray);

}


function _forums_get_parents($root_id, $ids=array()) {

	global $DB;

	$DB->query("SELECT * FROM `ibf_forums` WHERE `id` = '{$root_id}'");

	$fbyid = $DB->fetch_row();

	if ($fbyid['parent_id'] and $fbyid['parent_id'] != '-1' ) {

  $ids[] = $fbyid['parent_id'];

  

  $ids = _forums_get_parents($fbyid['parent_id'], $ids);

	}

	return $ids;

}


function _get_pages( $total, $pp, $id )

{

	global $ibforums, $forums, $LOFISKIN, $navarray;


	$page_array = array();


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

	// Get the number of pages

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


	$pages = ceil( $total / $pp );


	$pages = $pages ? $pages : 1;


	if ( $pages < 2 )

	{

  return "";

	}


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

	// Loppy loo

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


	if ($pages > 1)

	{

  for( $i = 0; $i <= $pages - 1; ++$i )

  {

 	 $RealNo = $i * $pp;

 	 $PageNo = $i+1;

 	 

 	 $page_array[] = "<a href='{$id}-{$RealNo}.html'>{$PageNo}</a>";

  }

  

	}


	return implode( ", ", $page_array );

}


//+-------------------------------------------------

// GLOBAL ROUTINES

//+-------------------------------------------------


function fatal_error($message="", $help="")

{

	echo("$message<br><br>$help");

	exit;

}





?>

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  

×