php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2008

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 21.01.2008, 15:22  
Neuer Benutzer
 
Registriert seit: 01.03.2007
Beiträge: 10
knox
Standard PHP Variablen via URL ändern

Hallo zusammen

Ich hab ein kleines Problem mit einem Foren-Skript. Da gibt es eine Datei mit dem Namen "recent.php" die standardmässig die letzten 100 Threats anzeigt und wie folgt aussieht ...

PHP-Code:
<?php
// ############ Edit below ############
$length '120'// length of topic title
$limit '100'// how many topics?
// ############ Edit above ############

define('IN_PHPBB'true);
$phpbb_root_path './';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.'.$phpEx);

$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);

$page_title $lang['Title'];
include(
$phpbb_root_path 'includes/page_header.'.$phpEx);

$sql "SELECT post_id FROM " POSTS_TABLE;
if ( !(
$result $db->sql_query($sql)) )
{
    
message_die(GENERAL_ERROR'Could not obtain matched posts list'''__LINE____FILE__$sql);
}
$recent_ids = array();
while( 
$row $db->sql_fetchrow($result) )
{
    
$recent_ids[] = $row['post_id'];
}
$db->sql_freeresult($result);

$recent_forum = ( isset($HTTP_POST_VARS['forum']) ) ? intval($HTTP_POST_VARS['forum']) : -1;
if ( 
$recent_forum == -)
{
        
$is_auth_ary auth(AUTH_READAUTH_LIST_ALL$userdata); 
        
$ignore_forum_sql '';
        while( list(
$key$value) = each($is_auth_ary) )
        {
                if ( !
$value['auth_read'] )
                {
                        
$ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' '' ) . $key;
                }
        }
        if ( 
$ignore_forum_sql != '' )
        {
                
$auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " "f.forum_id NOT IN ($ignore_forum_sql) ";
        }
}
                if ( 
$recent_author == '' && $auth_sql == '' )
                {
                        
$sql "SELECT topic_id FROM " POSTS_TABLE "
                                WHERE post_id IN (" 
implode(", "$recent_ids) . ") 
                                $where_sql GROUP BY topic_id"
;
                }
                else
                {
                        
$from_sql POSTS_TABLE " p"
                        if ( 
$auth_sql != '' )
                        {
                                
$from_sql .= ", " FORUMS_TABLE " f";
                                
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
                        }
                        
$sql "SELECT p.topic_id FROM $from_sql 
                                WHERE p.post_id IN (" 
implode(", "$recent_ids) . ") 
                                $where_sql GROUP BY p.topic_id"
;
                }
                if ( !(
$result $db->sql_query($sql)) )
                {
                        
message_die(GENERAL_ERROR'Could not obtain topic ids'''__LINE____FILE__$sql);
                }

                
$recent_ids = array();
                while( 
$row $db->sql_fetchrow($result) )
                {
                        
$recent_ids[] = $row['topic_id'];
                }
                
$db->sql_freeresult($result);

$auth_results implode(', '$recent_ids);
$sql "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
        FROM "
TOPICS_TABLE ." t, "FORUMS_TABLE ." f, "USERS_TABLE ." u, "POSTS_TABLE ." p, "POSTS_TABLE ." p2, "USERS_TABLE ." u2
        WHERE t.topic_id IN ($auth_results) 
              AND t.topic_poster = u.user_id
              AND f.forum_id = t.forum_id 
              AND p.post_id = t.topic_first_post_id
              AND p2.post_id = t.topic_last_post_id
              AND u2.user_id = p2.poster_id
        ORDER BY t.topic_last_post_id DESC LIMIT $limit"
;
if ( !
$result $db->sql_query($sql) )
{
        
message_die(GENERAL_ERROR'Could not obtain main information'''__LINE____FILE__$sql);
}
$line = array();
while( 
$row $db->sql_fetchrow($result) )
{
        
$line[] = $row;
}
$db->sql_freeresult($result);        
        
        
$template->set_filenames(array(
                
'body' => 'recent_body.tpl')
        );

        
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
        
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
        for(
$i 0$i count($line); $i++)
        {
                
$forum_url append_sid("viewforum.$phpEx?" POST_FORUM_URL '=' $line[$i]['forum_id']);
                
$forum_id $line[$i]['forum_id'];
                
$topic_url append_sid("viewtopic.$phpEx?" POST_TOPIC_URL '=' $line[$i]['topic_id']);
                
$topic_id $line[$i]['topic_id'];

                
$orig_word = array();
                
$replacement_word = array();
                
obtain_word_list($orig_word$replacement_word);
                
$word_censor = ( count($orig_word) ) ? preg_replace($orig_word$replacement_word$line[$i]['topic_title']) : $line[$i]['topic_title']; 
                
$topic_title = ( strlen($line[$i]['topic_title']) < $length ) ? $word_censor substr(stripslashes($word_censor), 0$length) . "..."

                
$topic_type = ( $line[$i]['topic_type'] == POST_ANNOUNCE ) ? $lang['Topic_Announcement'] .' ''';
                
$topic_type .= ( $line[$i]['topic_type'] == POST_STICKY ) ? $lang['Topic_Sticky'] .' ''';
                
$topic_type .= ( $line[$i]['topic_vote'] ) ? $lang['Topic_Poll'] .' ''';

                
$views $line[$i]['topic_views'];
                
$replies $line[$i]['topic_replies'];
                if ( ( 
$replies ) > $board_config['posts_per_page'] )
                {
                        
$total_pages ceil( ( $replies ) / $board_config['posts_per_page'] );
                        
$goto_page ' [ ';
                        
$times 1;
                        for(
$j 0$j $replies 1$j += $board_config['posts_per_page'])
                        {
                                
$goto_page .= '[url="' append_sid("]' . $times . '[/url]';
                                if ( $times == 1 && $total_pages > 4 )
                                {
                                        $goto_page .= ' ... ';
                                        $times = $total_pages - 3;
                                        $j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
                                }
                                else if ( $times < $total_pages )
                                {
                                        $goto_page .= ', ';
                                }
                                $times++;
                        }
                        $goto_page .= ' ] ';
                }
                else
                {
                        $goto_page = '';
                }

                if ( $line[$i]['topic_status'] == TOPIC_LOCKED )
                {
                        $folder = $images['folder_locked'];
                        $folder_new = $images['folder_locked_new'];
                }
                else if ( $line[$i]['topic_type'] == POST_ANNOUNCE )
                {
                        $folder = $images['folder_announce'];
                        $folder_new = $images['folder_announce_new'];
                }
                else if ( $line[$i]['topic_type'] == POST_STICKY )
                {
                        $folder = $images['folder_sticky'];
                        $folder_new = $images['folder_sticky_new'];
                }
                else
                {
                        if ( $replies >= $board_config['hot_threshold'] )
                        {
                                $folder = $images['folder_hot'];
                                $folder_new = $images['folder_hot_new'];
                        }
                        else
                        {
                                $folder = $images['folder'];
                                $folder_new = $images['folder_new'];
                        }
                }

                if ( $userdata['session_logged_in'] )
                {
                        if ( $line[$i]['post_time'] > $userdata['user_lastvisit'] ) 
                        {
                                if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
                                {
                                        $unread_topics = true;
                                        if ( !empty($tracking_topics[$topic_id]) )
                                        {
                                                if ( $tracking_topics[$topic_id] > $line[$i]['post_time'] )
                                                {
                                                        $unread_topics = false;
                                                }
                                        }
                                        if ( !empty($tracking_forums[$forum_id]) )
                                        {
                                                if ( $tracking_forums[$forum_id] > $line[$i]['post_time'] )
                                                {
                                                        $unread_topics = false;
                    }
                                        }
                                        if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
                                        {
                                                if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $line[$i]['post_time'] )
                                                {
                                                        $unread_topics = false;
                    }
                                        }
                                        if ( $unread_topics )
                                        {
                                                $folder_image = $folder_new;
                    $folder_alt = $lang['New_posts'];
                                $newest_img = '[url="' . append_sid("][img]'
$images['icon_newest_reply'] . '[/img][/url] ';
                                        }
                                        else
                                        {
                                                
$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                                
$folder_image $folder;
                    
$folder_alt $folder_alt;
                    
$newest_img '';
                                        }
                                }
                                else if ( 
$line[$i]['post_time'] > $userdata['user_lastvisit'] ) 
                                {
                                        
$folder_image $folder_new;
                                        
$folder_alt $lang['New_posts'];
                                        
$newest_img '[url="' append_sid("][img]'. $images['icon_newest_reply'] . '[/img][/url] ';
                                }
                                else 
                                {
                                        $folder_image = $folder;
                                        $folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                        $newest_img = '';
                                }
                        }
                        else
                        {
                                $folder_image = $folder;
                                $folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                $newest_img = '';
                        }
                }
                else
                {
                        $folder_image = $folder;
                        $folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_img = '';
                }
                
                $first_time = create_date($board_config['default_dateformat'], $line[$i]['topic_time'], $board_config['board_timezone']);
                $first_author = ( $line[$i]['user_id'] != ANONYMOUS ) ? '[url="' . append_sid("]'
.$line[$i]['username'].'[/url]' : ( ($line[$i]['post_username'] != '' ) ? $line[$i]['post_username'] : $lang['Guest'] ); 
                
$last_time create_date($board_config['default_dateformat'], $line[$i]['post_time'], $board_config['board_timezone']);
                
$last_author = ( $line[$i]['id2'] == ANONYMOUS ) ? ( ($line[$i]['post_username2'] != '' ) ? $line[$i]['post_username2'] . ' ' $lang['Guest'] . ' ' ) : '[url="' append_sid("]' . $line[$i]['user2'] . '[/url]';
                $last_url = '[url="' . append_sid("][img]'
$images['icon_latest_reply'] . '[/img][/url]';

                
$row_class = ( !($i 2) ) ? $theme['td_class1'] : $theme['td_class2'];

                
$template->assign_block_vars('recent', array(
                        
'TOPIC_TITLE' => $topic_title,
                        
'TOPIC_TYPE' => $topic_type,
                        
'VIEWS' => $views,
                        
'REPLIES' => $replies,
                        
'GOTO_PAGE' => $goto_page,
                        
'TOPIC_FOLDER_IMG' => '[img].$folder_image.[/img]'
                        
'NEWEST_IMG' => $newest_img
                        
'FIRST_TIME' => $first_time,
                        
'FIRST_AUTHOR' => $first_author,
                        
'LAST_TIME' => $last_time,
                        
'LAST_AUTHOR' => $last_author,
                        
'LAST_URL' => $last_url,
                        
'ROW_CLASS' => $row_class,
                        
'L_BY' => $lang['by'],
                        
'L_STARTED' => $lang['Started'],
                        
'L_REPLIES' => $lang['Replies'],
                        
'L_VIEWS' => $lang['Views'],
                        
'FORUM_NAME' => $line[$i]['forum_name'],
                        
'U_VIEW_FORUM' => $forum_url
                        
'FORUM_ID' => $forum_id,
                        
'U_VIEW_TOPIC' => $topic_url,
                        
'TOPIC_ID' => $topic_id
                
));
        }

        
$template->assign_vars(array(
                
'L_RECENT_TITLE' => $lang['Title']
        ));

$template->pparse('body');
include(
$phpbb_root_path 'includes/page_tail.'.$phpEx);
?>
Ich würde gern je nach Bedarf das Limit via URL ändern. Also so was wie

http://www.server.com/verzeichnis/recent.php?limit=500

Leider funktioniert es bei mir nicht. Weiss jemand was ich falsch mache?

Gruss Knox
knox ist offline  
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 21.01.2008, 17:03  
Erfahrener Benutzer
 
Benutzerbild von DER_Brain
 
Registriert seit: 18.04.2005
Beiträge: 1.541
PHP-Kenntnisse:
Fortgeschritten
DER_Brain ist zur Zeit noch ein unbeschriebenes Blatt
Standard

Hi
PHP-Code:
// ############ Edit below ############
$length '120'// length of topic title
$def 100// default value!

if(isset($_GET['limit'])){
  if(
is_numeric($_GET['limit'])){
    
$limit $_GET['limit'];
  }
  else{
    
$limit $def;
  }
}
else{
  
$limit $def
}
// ############ Edit above ############ 

lg
Andi

PS: Natürlich nur ein Weg..
DER_Brain ist offline  
Alt 23.01.2008, 23:06  
Neuer Benutzer
 
Registriert seit: 01.03.2007
Beiträge: 10
knox
Standard

@DER_Brain: Vielen Dank für deine Hilfe!!!
knox ist offline  
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Klasse statt globaler Variablen ecomeback PHP-Fortgeschrittene 6 15.07.2008 16:30
Templatesystem mit Funktionen und Variablen drin? BartTheDevil89 PHP Tipps 2008 6 01.07.2008 09:32
E-Mail Formular: Variablen in $message einfügen? thomas108 PHP Tipps 2008 9 02.06.2008 12:33
Übergeben von Variablen an in PHP eingebundenes Perl-Script shredder01 PHP Tipps 2008 3 04.04.2008 09:25
Datei mit Variablen so includen, dass Variablen nutzbar? BartTheDevil89 PHP Tipps 2008 6 22.01.2008 20:57
Variablen von Funktionen außerhalb nutzen Wing PHP Tipps 2008 5 28.09.2007 17:05
unerklärliches Leeren von Variablen KuShi PHP Tipps 2007 2 08.07.2007 15:19
Teil einer Variablen mit einer Variablen ersetzen ? simsalabim PHP Tipps 2007 11 20.03.2007 20:36
Variable aus Variablen zusammensetzen juhuwoorps PHP Tipps 2007 1 28.11.2005 21:50
Variablen übergeben PHP Tipps 2005-2 9 30.08.2005 10:58
Variablen übergeben bzw. auslesen? PHP Tipps 2005 4 30.01.2005 03:56
[Erledigt] register globals off bei variablen Variablen... PHP Tipps 2005 4 25.01.2005 17:50
komplexe Variablen übergeben? PHP Tipps 2004-2 8 02.12.2004 08:29
Variablen Namen zuweisen dh1sbg PHP Tipps 2004-2 3 12.11.2004 17:12
Variablen per adresse übergeben rocco PHP Tipps 2004 7 24.07.2004 12:03

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
phpbb_root_path ändern, php variablen in der url verändern, url via php verändern, php variable url manipulieren, variablen in url ändern, php variable in url ändern, serverseitige scriptausführung url verändern php, phpbb_root_path ändern für urls, url ändern php, \icon_newest_reply ändern\

Alle Zeitangaben in WEZ +2. Es ist jetzt 19:14 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.