vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   prefix_rich in front of threads (https://vborg.vbsupport.ru/showthread.php?t=214312)

enteha 05-22-2009 05:59 PM

prefix_rich in front of threads
 
Hi, I am trying to modify a php file that is about latest thread and post scrolling. This file as ready to use but I want to add an ability to show prefix name at the start os thread.I don`t know what variable control prefix rich.can anybody help me? the php file I said is here:

PHP Code:

<?php
/
// ######################### REQUIRE BACK-END ############################
require_once('./includes/config.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";

$forum_path "."// Change this to reflect to your forum's Path.
$specific_forum_id ""// If you wish to display the posts from a specific forum, enter the forum id here. Otherwise, leave it blank.
$ignore_forum_id_a ""// If you dont wish to display the posts from a specific forum, enter the forum id here. Otherwise, leave it blank.
$ignore_forum_id_b "";
$ignore_forum_id_c "";
$ignore_forum_id_d "";
$ignore_forum_id_e "";
$ignore_forum_id_f "";
$ignore_forum_id_g "";
$ignore_forum_id_h "";
$lastpost_limit "20"// Number of posts displayed.
$title_color "#006600"// This is the color of the title.
$text_color "#CC3300"// This is the color of the bottom text.
$title_limit "100"// This is the character limit.
echo"<marquee onmouseover=this.stop() onmouseout=this.start() dir=\"rtl\" direction=\"up\" scrollAmount=\"2\" scrolldelay=\"50\">";
echo 
"<table dir=\"rtl\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
$sforumid '';
$iforumida '';
$iforumidb '';
$iforumidc '';
$iforumidd '';
$iforumide '';
$iforumidf '';
$iforumidg '';
$iforumidh '';
if (
$specific_forum_id) {
    
$sforumid "AND forumid = $specific_forum_id";
}
if (
$ignore_forum_id_a) {
    
$iforumida "AND forumid != $ignore_forum_id_a";
}
if (
$ignore_forum_id_b) {
    
$iforumidb "AND forumid != $ignore_forum_id_b";
}
if (
$ignore_forum_id_c) {
    
$iforumidc "AND forumid != $ignore_forum_id_c";
}
if (
$ignore_forum_id_d) {
    
$iforumidd "AND forumid != $ignore_forum_id_d";
}
if (
$ignore_forum_id_e) {
    
$iforumide "AND forumid != $ignore_forum_id_e";
}
if (
$ignore_forum_id_f) {
    
$iforumidf "AND forumid != $ignore_forum_id_f";
}
if (
$ignore_forum_id_g) {
    
$iforumidg "AND forumid != $ignore_forum_id_g";
}
if (
$ignore_forum_id_h) {
    
$iforumidh "AND forumid != $ignore_forum_id_h";
}
if (
$lastpost_limit) {
    
$lastpost_limited "LIMIT $lastpost_limit";
}
        
//dtabase connection
$server $config['MasterServer']['servername'];
$databaseuser $config['MasterServer']['username'];
$databasepass $config['MasterServer']['password'];
$databasename $config['Database']['dbname'];
$table_prefix $config['Database']['tableprefix'];
$conn mysql_connect("$server""$databaseuser""$databasepass") or die ('database error');
mysql_select_db("$databasename"$conn) or die ('database error');
        
//thread table sql query
$thread_sql_query mysql_query("SELECT threadid,title,lastpost,lastposter,forumid,postusername,lastpostid FROM " $table_prefix "thread WHERE visible=1 AND open=1 $sforumid $iforumida $iforumidb $iforumidc $iforumidd $iforumide $iforumidf $iforumidg $iforumidh ORDER BY lastpost DESC $lastpost_limited");
while(
$thread_get_info mysql_fetch_array($thread_sql_query))
{
    
$lastpost $thread_get_info['lastpost'];
    
$lastposter $thread_get_info['lastposter'];
    
$threadid $thread_get_info['threadid'];
    
$forumid $thread_get_info['forumid'];
    
$postusername $thread_get_info['postusername'];
    
$lastpostid $thread_get_info['lastpostid'];
    
$date date ("m/d/y h:i A" ,$lastpost);
    
$threadtitle $thread_get_info['title'];
    
$threadtitle substr($threadtitle,0,$title_limit);
    
        
//forum table sql query
    
$forum_sql mysql_query("SELECT title FROM " $table_prefix "forum WHERE forumid=$forumid");
    
$forum_get mysql_fetch_array($forum_sql);
    
$forumtitle $forum_get['title'];
    
        
//post table sql query
    
$post_sql mysql_query("SELECT title,postid FROM " $table_prefix "post WHERE postid=$lastpostid");
    
$post_get mysql_fetch_array($post_sql);
    
$lastposterid $post_get['postid'];
    
$lastposttitle $post_get['title'];
    if (empty(
$lastposttitle)) {
        
$lastposttitle = ("response: $threadtitle");    
    }
    
$lastposttitle substr($lastposttitle,0,$title_limit);
    echo 
"<tr dir=\"rtl\"><td dir=\"rtl\"><font size=\"2\" face=\"utf-8\"><a target=_blank href=\"$forum_path/showthread.php?p=$lastposterid#post$lastposterid\"><FONT SIZE=\"4\" COLOR=\"$title_color\" face=\"tahoma\">$threadtitle</FONT></a></font><br> <font color=\"$text_color\" face=\"tahoma\" size='2'>Starter : $postusername |forum :  $forumtitle | last post :  $lastposter </FONT></td></tr>";
}
echo 
"</table>";
echo
"</marquee>";
/*======================================================================*\
|| ##################################################################### ||
|| ############################ END SCRIPT ############################# ||
|| ##################################################################### ||
\*======================================================================*/


I knew that I should write a line such:

$threadtitle = $thread_get_info['title'];

but I don`t know how?

Lynne 05-22-2009 06:22 PM

Include grabbing the prefixid from the thread table in your query. Then in your while statement:
PHP Code:

                if ($thread_get_info['prefixid']) 
                { 
                    
$thread_get_info['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_$thread_get_info[prefixid]_title_plain"]); 
                    
$thread_get_info['prefix_rich'] = $vbphrase["prefix_$thread_get_info[prefixid]_title_rich"]; 
                } 
                else 
                { 
                    
$thread_get_info['prefix_plain_html'] = ''
                    
$thread_get_info['prefix_rich'] = ''
                } 

If you don't want the plain html one, then you may remove those lines.

enteha 05-23-2009 09:38 AM

tahnk you Lynne, I added this code to php file but I got errors and didn`t work :( I have alittle understanding about php. can you make it easier?

Lynne 05-23-2009 03:52 PM

Without seeing exactly what you've done, and knowing what the exact errors were, I can't really help.

enteha 05-24-2009 09:19 AM

I said that I have a little understanding about php and I want to make a marquee scroller included latest tapics at the top of the board (see: here). I found this one and I decided to make some modifying to show thread`s prefixes in title and then I need some helps.

Lynne 05-24-2009 02:44 PM

I know. But, I gave you some code and you said you added the code to the file and got errors. So, can you post the file again with the added code so I can see if you added it correctly. And, can you post what the errors were that you got.

enteha 05-25-2009 10:19 AM

tahnx for help and supporting. I change php file as this:

PHP Code:

<?php
// ######################### REQUIRE BACK-END ############################
require_once('./includes/config.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";

$forum_path "."// Change this to reflect to your forum's Path.
$specific_forum_id ""// If you wish to display the posts from a specific forum, enter the forum id here. Otherwise, leave it blank.
$ignore_forum_id_a ""// If you dont wish to display the posts from a specific forum, enter the forum id here. Otherwise, leave it blank.
$ignore_forum_id_b "536";
$ignore_forum_id_c "";
$ignore_forum_id_d "";
$ignore_forum_id_e "";
$ignore_forum_id_f "";
$ignore_forum_id_g "";
$ignore_forum_id_h "";
$lastpost_limit "20"// Number of posts displayed.
$title_color "#0079c3"// This is the color of the title.
$text_color "#C11B17"// This is the color of the bottom text.
$title_limit "160"// This is the character limit.
echo"<marquee onmouseover=this.stop() onmouseout=this.start() dir=\"rtl\" direction=\"up\" scrollAmount=\"2\" scrolldelay=\"50\">";
echo 
"<table dir=\"rtl\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
$sforumid '';
$iforumida '';
$iforumidb '';
$iforumidc '';
$iforumidd '';
$iforumide '';
$iforumidf '';
$iforumidg '';
$iforumidh '';
if (
$specific_forum_id) {
    
$sforumid "AND forumid = $specific_forum_id";
}
if (
$ignore_forum_id_a) {
    
$iforumida "AND forumid != $ignore_forum_id_a";
}
if (
$ignore_forum_id_b) {
    
$iforumidb "AND forumid != $ignore_forum_id_b";
}
if (
$ignore_forum_id_c) {
    
$iforumidc "AND forumid != $ignore_forum_id_c";
}
if (
$ignore_forum_id_d) {
    
$iforumidd "AND forumid != $ignore_forum_id_d";
}
if (
$ignore_forum_id_e) {
    
$iforumide "AND forumid != $ignore_forum_id_e";
}
if (
$ignore_forum_id_f) {
    
$iforumidf "AND forumid != $ignore_forum_id_f";
}
if (
$ignore_forum_id_g) {
    
$iforumidg "AND forumid != $ignore_forum_id_g";
}
if (
$ignore_forum_id_h) {
    
$iforumidh "AND forumid != $ignore_forum_id_h";
}
if (
$lastpost_limit) {
    
$lastpost_limited "LIMIT $lastpost_limit";
}
        
//dtabase connection
$server $config['MasterServer']['servername'];
$databaseuser $config['MasterServer']['username'];
$databasepass $config['MasterServer']['password'];
$databasename $config['Database']['dbname'];
$table_prefix $config['Database']['tableprefix'];
$conn mysql_connect("$server""$databaseuser""$databasepass") or die ('database error');
mysql_select_db("$databasename"$conn) or die ('database error');
        
//thread table sql query
$thread_sql_query mysql_query("SELECT threadid,title,lastpost,lastposter,forumid,postusername,lastpostid,replycount,views,prefixid,prefix_plain_html FROM " $table_prefix "thread WHERE visible=1 AND open=1 $sforumid $iforumida $iforumidb $iforumidc $iforumidd $iforumide $iforumidf $iforumidg $iforumidh ORDER BY lastpost DESC $lastpost_limited");
while(
$thread_get_info mysql_fetch_array($thread_sql_query))
{
    
$lastpost $thread_get_info['lastpost'];
    
$lastposter $thread_get_info['lastposter'];
    
$threadid $thread_get_info['threadid'];
    
$forumid $thread_get_info['forumid'];
    
$postusername $thread_get_info['postusername'];
    
$lastpostid $thread_get_info['lastpostid'];
    
$date date ("m/d/y h:i A" ,$lastpost);
    
$threadtitle $thread_get_info['title'];
    
$threadtitle substr($threadtitle,0,$title_limit);
    
$replycount $thread_get_info['replycount'];
    
$views $thread_get_info['views'];
                if (
$thread_get_info['prefixid']) 
                { 
                    
$thread_get_info['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_$thread_get_info[prefixid]_title_plain"]); 
                    
$thread_get_info['prefix_rich'] = $vbphrase["prefix_$thread_get_info[prefixid]_title_rich"]; 
                } 
                else 
                { 
                    
$thread_get_info['prefix_plain_html'] = ''
                    
$thread_get_info['prefix_rich'] = ''
                } 
    
        
//forum table sql query
    
$forum_sql mysql_query("SELECT title FROM " $table_prefix "forum WHERE forumid=$forumid");
    
$forum_get mysql_fetch_array($forum_sql);
    
$forumtitle $forum_get['title'];
    
        
//post table sql query
    
$post_sql mysql_query("SELECT title,postid FROM " $table_prefix "post WHERE postid=$lastpostid");
    
$post_get mysql_fetch_array($post_sql);
    
$lastposterid $post_get['postid'];
    
$lastposttitle $post_get['title'];
    if (empty(
$lastposttitle)) {
        
$lastposttitle = ("?™¾?˜§?˜³?˜®: $threadtitle");    
    }
    
$lastposttitle substr($lastposttitle,0,$title_limit);
    echo 
"<tr dir=\"rtl\"><td dir=\"rtl\"><font size=\"2\" face=\"utf-8\"><a target=_blank href=\"$forum_path/showthread.php?p=$lastposterid#post$lastposterid\"><FONT SIZE=\"4\" COLOR=\"$title_color\" face=\"tahoma\">$threadtitle</FONT></a></font><br> <font color=\"$text_color\" face=\"tahoma\" size='2'>ا?Œجاد ک?†?†د?‡ ?…?ˆض?ˆع: $postusername | تا?„ار :  $forumtitle | بازد?Œد :  $prefix_plain_html | پاسخ :  $replycount | آخر?Œ?† ارسا?„: $lastposter</FONT></td></tr>";
}
echo 
"</table>";
echo
"</marquee>";
/*======================================================================*\
|| ##################################################################### ||
|| ############################ END SCRIPT ############################# ||
|| ##################################################################### ||
\*======================================================================*/

and got this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /[root address]/forums/latest_posts2.php on line 83

Lynne 05-25-2009 03:57 PM

There is no "prefix_plain_html" field in the thread table, so I'm not sure why you included that. Take it out and see if the error goes away.

enteha 05-26-2009 12:24 PM

Hi, I removed that part and now I got this error:

Fatal error: Call to undefined function htmlspecialchars_uni() in /[root address]/forums/latest_posts2.php on line 98

Lynne 05-26-2009 01:12 PM

That function is in the file includes/class_core.php so you'll need to either include the file in your plugin (require_once etc.) or copy the function into your page.

enteha 05-27-2009 12:35 AM

I said that I have no php understanding :( I can`t do this but thanx for your consideration.


All times are GMT. The time now is 05:50 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01447 seconds
  • Memory Usage 1,883KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete