PDA

View Full Version : اشکال در این فایل پی اچ پی



Sayrex
یک شنبه 21 خرداد 1385, 19:26 عصر
سلام :

من فرومم Phpbb هست یک اسکرول برای سابت داشتم که با صفحات سایتم کار میکرد و 30 پست آخر فروم رو برای کاربران به صورت اسکرول نشون میداد .

کد اسکرول قبلی که با صفحات را به صورت Php ارایه میداد :


<?php
// Basic Configuration
// How Many Topics you want to display?
$topicnumber = 30;
// Scrolling towards up or down?
$scroll = "up";
// Change this to your phpBB path
$urlPath = "http://www.siscenter.com/forum";
// Database Configuration (Where your phpBB config.php file is located
include 'config.php';
// Connecting & Selecting Databases
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");
// Perform Sql Query
$query = "SELECT t.topic_poster,t.topic_views,t.topic_replies,t.top ic_id, t.topic_title, t.topic_last_post_id,
t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username ,f.forum_name
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.topic_status <> 2 AND
t.forum_id <> 30 AND
t.forum_id <> 50 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");
// Outcome of the HTML
// Be carefull when you edit these!
print "<marquee dir=\"rtl\" align=\"center\" id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"150\" width=\"100%\" scrolldelay=\"100\" scrollamount=\"2\" onMouseOver=\"stop()\" onMouseOut=\"start()\">";
print "<div align=\"center\">";
print "<table cellpadding='3' cellSpacing='2'";

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$forum_no = $row["forum_id"];
if (($forum_no <> 34) and ($forum_no <> 39 ) and ($forum_no <> 41 ))
{
echo
"<tr valign='top'>
<td><font face=\"Tahoma\" size=\"1\"><font color=\"#FFCC00\"><b> </b><font color=\"#978981\"> &atilde;&aelig;&Ouml;&aelig;&Uacute; :
<a href=\"$urlPath/viewtopic.php?p=$row[topic_last_post_id]#$row[topic_la st_post_id]\">
<span style=\"text-decoration: none\">" . $row["topic_title"] .

"</span></a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#978981\"> &Ccedil;&auml;&Igrave;&atilde;&auml; :
<font color=\"#978981\">
<$urlPath/viewtopic.php?p=$row[topic_last_post_id]#$row[topic_last_pos t_id]>" . $row["forum_name"] .
"</td><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .

"</span></a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#978981\"> &Egrave;&Ccedil;&Ograve;&Iuml;&iacute;&Iuml;&aring;&Ccedil; :
<font color=\"#978981\">
<$urlPath/viewtopic.php?p=$row[topic_last_post_id]#$row[topic_last_pos t_id]>" . $row["topic_views"] .
"</td><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .

"</span></a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#978981\"> &Ccedil;&Oacute;&Icirc; &aring;&Ccedil; :
<font color=\"#978981\">
<$urlPath/viewtopic.php?p=$row[topic_last_post_id]#$row[topic_last_pos t_id]>" . $row["topic_replies"] .
"</td><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .

"</span></a></td></font></b><td><font face=\"Tahoma\" size=\"1\"><font color=\"#978981\"> &Acirc;&Icirc;&Ntilde;&iacute;&auml; &Ccedil;&Ntilde;&Oacute;&Ccedil;&aacute; :
<a href=\"$urlPath/profile.php?mode=viewprofile&u=$row[user_id]\">" . $row["username"] .
"</td><td><font face=\"Tahoma\" size=\"1\"><font color=\"#C0C0C0\">" .

"</td></tr></font>";


}}
print "</table></div></marquee>";
// Free Result
mysql_free_result($result);
// Close the Connection
mysql_close($link);
?>


توسط Add on ای صفحات رو برای بهتر ایندکس شدن بهHtml تبدیل کردم ولی از آنجایی که اسکرول قبلی با صفحات رو هنوزم به شکل Php میشناخت امکان استفاده از آن در فروم نبود . در نتیجه با ÷یگیری های صورت گرفته با نویسنده آن Add on ایون برای ما اسکرولی ساخته اند به شکل زیر :


<?php
// Last XX Active Topics outside phpBB - dcz - www.phpBB-SEO.com
// License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
//
// Basic Configuration
// How Many Topics you want to display?
define('IN_PHPBB', true);

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

// Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// End session management

$topicnumber = 30;
// Scrolling towards up or down?
$scroll = "up";
// Change this to your phpBB URL
$urlPath = "http://www.siscenter.com/forum";
// Change this to your phpBB path
$phpbb_root_path = 'forum/';
// Exclude forums, forum id in this array will not be listed
$exclude_forum = array (
//1 => 31,
//2 => 5,
//3 => 10,
);


// Let's do it now ;-)
$sql = "SELECT t.topic_poster,t.topic_views,t.topic_replies,t.top ic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username ,f.forum_name
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
AND t.topic_status <> 2
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
//Begin sql cache
if ( !($result = $db->sql_query($sql)) )
//if ( !($result = $db->sql_query($sql, false, 'posts_')) )
//End sql cache
{
message_die(GENERAL_ERROR, 'Could not obtain Last topics info', '', __LINE__, __FILE__, $sql);
}
$last_topic_data = array();
while( $row = $db->sql_fetchrow($result) )
{
$last_topic_data[] = $row;
}
$db->sql_freeresult($result);
unset($row);

// Handle the not topics case, if you want :-)
if ( !($total_topics = count($last_topic_data)) )
{
$message = 'Something you want to say here ;-)';
message_die(GENERAL_MESSAGE, $message);
}

//
// Find which forums are visible for this user
//
$is_auth_ary = array();
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $last_topic_data);

// here I keep the basic html output
// Outcome of the HTML
// Be carefull when you edit these!
print "<marquee dir=\"rtl\" align=\"center\" id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"150\" width=\"100%\" scrolldelay=\"100\" scrollamount=\"2\" onMouseOver=\"stop()\" onMouseOut=\"start()\">";
print "<div align=\"center\">";
print "<table cellpadding='3' cellSpacing='2'";
for ($i = 0; $i < $total_topics; $i++ )
{
if ($is_auth_ary[$last_topic_data[$i]['forum_id']]['auth_view'] && !in_array($last_topic_data[$i]['forum_id'], $exclude_forum))
{

echo "<tr valign='top'>
<td><span class=\"nav\">".$lang['Last_Post']." :
<a href=\"".append_sid("$urlPath/viewtopic.php?t=".$last_topic_data[$i]['topic_id'])."\" class=\"nav\">" . $last_topic_data[$i]['topic_title'] ."</span></a></td>
<td><span class=\"nav\"> ".$lang['Poster']." :
<a href=\"".append_sid("$urlPath/profile.php?mode=viewprofile&u=".$last_topic_data[$i]['user_id'])."\" class=\"nav\" >" . $last_topic_data[$i]['username'] . "</a></td></tr>";

}
}
echo "</table></div></marquee>";
// Free Result
mysql_free_result($result);
// Close the Connection
mysql_close($link);
?>

این اسکرول درست کار میکنه اما به هیچ وجه نمیشه اون رو در فروم استفاده کرد . چون در هر کجا از فروم که قرار بگیره یا صفحه رو بهم میریزه و نمایش نمیده یا قادر به اجرای دستورات بعد از دستورات این اسکرول نیست .

اسکرول قدیم در قسمتی از فروم توسط دستور include فراخوانی میشد و نمایش داده میشه . مصل تمامی سایتهایی که از اسکرول استفاده میکنند . اما این اسکرول جدید نمیشه باهاش این کار رو کرد .

من فکر میکنم یه ایرادی در برنامه نویسی این اسکرول وجود داره که اجازه نمیده دستورات بعد از قرار گرفتن اون در قسمتهای مختلف فروم اجرا بشوند .

از دوستانی که به زبان Php آشنایی داردند خواهش میکنم یه بازبینی بکنند این برنامه رو ببینند چیزی توش وجود داره که اینگونه میشه .

با تشکر