создаю я свой портал, зделал страничку с новостями и теперь к ней решил присоединить мод каторый выводит последние сообщения с форума вобщем ценити сами:
Код страницы с новостями и с подгрузкой мода каторый выводит последнии сообщения с форума:
Находясь на нашем сайте, вы соглашаетесь на использование файлов cookie, а также с нашим положением о конфиденциальности Политика конфиденциальности и пользовательским соглашением Условия использования.
Вопрос
bgd
Вот такя вот фигня:
создаю я свой портал, зделал страничку с новостями и теперь к ней решил присоединить мод каторый выводит последние сообщения с форума вобщем ценити сами:
Код страницы с новостями и с подгрузкой мода каторый выводит последнии сообщения с форума:
<?php if ( ! defined( 'IN_IPB' ) ) { print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit(); } class forumnews { var $ipsclass = ''; var $output = ""; var $page_title = ""; var $nav2 = array(); var $parser = ""; var $html = ""; #******************************# function auto_run(){ #******************************# $this->ipsclass->load_template('skin_help'); $this->base_url = "{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}?act=forumnews"; $this->base_path = './sources/action_public/'; $this->page_title = 'HIP-HOP CULTURE (HHC) -> Новости'; $this->nav = array( "<a href='$this->base_url'>" .$this->page_title . "</a>\n" ); if($_REQUEST['CODE']){ $action=$_REQUEST['CODE']; }else{ $action=''; } switch ( $action) { case '01': $output=$this->forumnews_main(); break; default: $output=$this->forumnews_main(); break; } $this->ipsclass->print->add_output("$output"); $this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, 'NAV'=>$this->nav2) ); } function forumnews_main(){ $forumnews_forum_prefix = "ibf_"; $forumnews_forum_id = "42"; $forumnews_forum_url = "http://www.hip-hop.metroland.ru/forum"; $forumnews_news_size = "500"; $forumnews_txt = <<< EOF <div class="borderwrap" style="display:none" id="fc_forumnews"> <div class="maintitlecollapse"> <p class="expand"><a href="java script:togglecategory('forumnews', 0);"><img src='style_images/<#IMG_DIR#>/exp_plus.gif' border='0' alt='Развернуть' /></a></p> <p><img src='style_images/<#IMG_DIR#>/nav_m.gif' border='0' alt='>' width='8' height='8' /> <a href="{$this->base_url}">Forum News</a></p> </div> </div> <div class="borderwrap" style="display:show" id="fo_forumnews"> <div class="maintitle"> <p><img src='style_images/<#IMG_DIR#>/nav_m.gif' border='0' alt='>' width='8' height='8' /> <a href="{$this->base_url}">Новости</a></p> </div> <table class='ipbtable' cellspacing="1"> <tr> EOF; $sql = "SELECT * FROM `" . $forumnews_forum_prefix . "topics` WHERE forum_id = " . $forumnews_forum_id . " ORDER BY `start_date` DESC LIMIT 0, 8"; $result = mysql_query($sql); $i=0; while ( $topic = mysql_fetch_array( $result ) ) { $i = $i+1; $sql = "SELECT * FROM `" . $forumnews_forum_prefix . "posts` WHERE topic_id = " . $topic['tid'] . " LIMIT 0, 1 "; $result2 = mysql_query($sql); while ( $post = mysql_fetch_array( $result2 ) ) { $dt = date("d.m.y - H:i:s", $topic['start_date']); $post['post'] = str_replace("style_emoticons/<#EMO_DIR#>/", $forumnews_forum_url . "/style_emoticons/default/", $post['post']); $post['post'] = str_replace(" />", "/>", $post['post']); $forumnews_news_size_now = strlen($post['post']); if ( $forumnews_news_size_now < $forumnews_news_size) { $forumnews_news_size_new = $forumnews_news_size_now; } else { if (strlen($post['post']) < $forumnews_news_size + 100) { $forumnews_news_size_new = strlen($post['post']); } else { $forumnews_news_size_new = $forumnews_news_size + 100; } $post['post'] = substr($post['post'], 0, $forumnews_news_size_new); $forumnews_news_size_new = strpos($post['post'], " ", $forumnews_news_size); if ( strpos($post['post'], "<a ", $forumnews_news_size) ) { $forumnews_news_size_new = strpos($post['post'], "<a ", $forumnews_news_size); } } $post['post'] = substr($post['post'], 0, $forumnews_news_size_new); $i2 = $i/2; if ($i2 != round($i2)) { $forumnews_txt .= " </tr><tr>"; } $forumnews_txt .= " <td class=\"row2\" width=\"50%\" valign=\"top\"><a href=\"" . $forumnews_forum_url . "/index.php?showtopic=" . $post['topic_id'] ."\" target=\"_blank\"><b>" . $topic['title'] . "</b></a><br /><span class=\"forumdesc\">"; if ( $forumnews_news_size < $forumnews_news_size_now ) { $post['post'] .= "<a href=\"" . $forumnews_forum_url . "/index.php?showtopic=" . $post['topic_id'] ."\" target=\"_blank\">...</a>"; } $post['post'] .= "<br /></span>"; $sql = "SELECT * FROM `" . $forumnews_forum_prefix . "attachments` WHERE attach_pid = " . $post['pid']; $result3 = mysql_query($sql); $forumnews_txt .= "<div align=\"left\" valign=\"top\">"; while ( $attach = mysql_fetch_array( $result3 ) ) { if ($attach['attach_is_image'] == 1) { if ($attach['attach_thumb_height'] == 0) { $attach['attach_thumb_location'] = $attach['attach_location']; } //$forumnews_txt .= "<a href=\"" . $forumnews_forum_url . "/uploads/" . $attach['attach_location'] . "\" target=\"_blank\"><img src=\"" . $forumnews_forum_url . "/uploads/" . $attach['attach_thumb_location'] . "\" align='left'></a>"; } else { $forumnews_txt .= "Прикреплено к сообщению: <a href=\"" . $forumnews_forum_url . "/index.php?act=Attach&type=post&id=" . $attach['attach_id'] . "\" target=\"_blank\" >" . $attach['attach_file'] . "</a>"; } } $forumnews_txt .= " " . $post['post'] . "<br><div align=\"right\"><a href=\"" . $forumnews_forum_url . "/index.php?showtopic=" . $post['topic_id'] ."\" target=\"_blank\">Подробнее</a><br><a href=\"" . $forumnews_forum_url . "/index.php?showuser=" . $post['author_id'] . "\" target=\"_blank\">" . $post['author_name'] . "</a> - " . $dt . "</td>"; } } $forumnews_txt .= <<< EOF </tr><tr> </tr> </table> </div><br> <div class="borderwrap" style="display:none" id="fc_forumnews"> <div class="maintitlecollapse"> <p><img src='style_images/<#IMG_DIR#>/nav_m.gif' border='0' alt='>' width='8' height='8' /> <a href="{$this->base_url}">Forum News</a></p> </div> </div> <div class="borderwrap" style="display:show" id="fo_forumnews"> <div class="maintitle"> <p><img src='style_images/<#IMG_DIR#>/nav_m.gif' border='0' alt='>' width='8' height='8' /> <a href="{$this->base_url}">Последние обсуждения</a></p> </div> <table class='ipbtable' cellspacing="1"> <table width="100%" border="1"> <tr> <td class="row2"> </tr> <tr> </tr> </table> </div> EOF; include("latest_posts.php"); return $forumnews_txt; } } ?>Код latest_posts.php:
<? // ******************************************* // // Создатель оригинального мода Miles Johnson. // // Перевод и улудшение HungerGhost // // ******************************************* // $posts = 10; $showtopiclength = 1; $topiclength = 40; $forumexclude = "1"; $datedisplay = 'd F Y'; $timedisplay = 'h:i A T'; require "ips_kernel/class_db_mysql.php"; require "conf_global.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->connect(); $getposts = $db->query("SELECT posts, last_poster_name, last_poster_id, title, tid, forum_id, last_post FROM ibf_topics WHERE (forum_id NOT IN ($forumexclude)) ORDER BY last_post DESC LIMIT $posts"); while ($post = $db->fetch_row($getposts)) { $post[full_title] = $post[title]; if ($showtopiclength == 1 AND strlen($post[full_title]) > $topiclength) { $post[short_title] = substr($post[full_title],0,$topiclength); $post[short_title] = $post[short_title]."..."; } else { $post[short_title] = $post[full_title]; } $posted_on = date($datedisplay, $post[last_post]); $today_date = date($datedisplay, time()); If ($posted_on == $today_date) { $datefield = "Сегодня"; $datefield = $datefield . ", " . date($timedisplay, $post[last_post]); } elseif (date('d F Y',strtotime("-1 day")) == $posted_on) { $datefield = "Вчера"; $datefield = $datefield . ", " . date($timedisplay, $post[last_post]); } else { $datefield = $today_date; } echo <<<EOF <a href="$INFO[board_url]/index.php?showtopic=$post[tid]&view=getnewpost">$post[short_title]</a> by <a href="$INFO[board_url]/index.php?showuser=$post[last_poster_id]">$post[last_poster_name]</a> <BR> $datefield, и $post[posts] ответов.<P> EOF; } ?>Почему то страничка не работает, подскажите почему!
Ссылка на комментарий
Поделиться на других сайтах
1 ответ на этот вопрос
Рекомендуемые сообщения
Присоединиться к обсуждению
Вы можете ответить сейчас, а зарегистрироваться позже. Если у вас уже есть аккаунт, войдите, чтобы ответить от своего имени.