Jump to content
php.lv forumi

Jaunumu scripts.


PIPARIns :*

Recommended Posts

<?php
$cfg['latest_pos']  = "DESC"; //Jaunaakie raksti buus kur (DESC = Augsaa, ASC = Apaksaa)
$cfg['news_limit']  = "20"; //Kopeejais jaunumu limits (0 - izslegts)
$cfg['no_news']     = "Nav jaunumu."; //Message to Display when there are no News
$cfg['page_select'] = "false"; //Rādīt lapu pārslēdzēju? (true, false)
$cfg['debug']       = "false"; //DEBUG MODE -- MAKE SURE YOU KNOW WHAT YOU ARE DOING

##########################################################################################

require_once "load.config.sys.php"; //Load config

$cfg['forum_path']  = $root . $forummap;
$cfg['forum_mape']  = $forummap;
$cfg['per_page']    = $newslimit;
$INFO['sql_tbl_prefix']  = $prefix;
$cfg['forums_id'][] = $newsforum;

for ($i = 0; $i < count( $cfg['forums_id'] ); $i++ ) {
   $cfg['forum_id'] = $cfg['forums_id'][$i];

   if ( $cfg['news_limit'] != "0" ) {
       $query = mysql_query( "SELECT t.tid, t.title, t.topic_firstpost, p.pid, p.topic_id, p.post_date, p.author_id, m.id, m.name, p.post, t.posts
                              FROM ". $INFO['sql_tbl_prefix'] ."topics t, ". $INFO['sql_tbl_prefix'] ."posts p, ". $INFO['sql_tbl_prefix'] ."members m
                              WHERE t.forum_id = '". $cfg['forum_id'] ."'
                                  AND t.tid = p.topic_id
                                  AND p.author_id = m.id
                                  AND p.pid = t.topic_firstpost
                              ORDER BY p.post_date ". $cfg['latest_pos'] ."
                              LIMIT ". $cfg['news_limit'] );
   } else {
       $query = mysql_query( "SELECT t.tid, t.title, t.topic_firstpost, p.pid, p.topic_id, p.post_date, p.author_id, m.id, m.name, p.post, t.posts
                              FROM ". $INFO['sql_tbl_prefix'] ."topics t, ". $INFO['sql_tbl_prefix'] ."posts p, ". $INFO['sql_tbl_prefix'] ."members m
                              WHERE t.forum_id = '". $cfg['forum_id'] ."'
                                  AND t.tid = p.topic_id
                                  AND p.author_id = m.id
                                  AND p.pid = t.topic_firstpost
                              ORDER BY p.post_date ". $cfg['latest_pos'] );
   }

   if ( !$query ) {
       die( "<b>mysql_query()</b>: ". mysql_error() );
   }

   $iNews    = mysql_num_rows( $query );
   $iRun     = 0;
   $iCurrent = 0;

   if ( $iNews == 0 ) {
       echo "<span style=\"font-family: Tahoma; font-size: 13px\">". $cfg['no_news'] ."</span>";
   }

   while ( $row = mysql_fetch_array( $query, MYSQL_NUM ) ) {
       if ( $cfg['debug'] == "true" ) {
           print_r( $row );
       }

       $iRun++;
       if ( $iRun > ( $_GET['pg'] - 1 ) * $cfg['per_page'] && $iCurrent < $cfg['per_page'] ) {

   /* EDIT THE DISPLAY DESIGN BELOW - CAREFUL (BEGIN) */
$sTemplate = <<<EOT
<div class="text-box"><div style="float:right;display:inline;">Pievienoja <a href="f/index.php?showuser=<!-- USER -->"/><!-- AUTHOR --></a>.</div><div style="font-size:110%;font-weight:bold;display:inline"><!-- TITLE --></div><div class="newsitem"><!-- POST --></div><div style="text-align:right"><!-- TIME --></div></div><div class="line"></div>
EOT;
/* EDIT THE DISPLAY DESIGN BELOW - CAREFUL (END) */

           $sParsed = str_replace( array( "<!-- TITLE -->",
                                          "<!-- POST -->",
                                          "<!-- TIME -->",
                                          "<!-- AUTHOR -->",
                                          "<!-- REPLIES -->",
                                          "<!-- FORUM -->",
                                          "<!-- TOPIC -->",
                                          "style_emoticons/<#EMO_DIR#>", //SMILEY FIX
                                          "<!-- USER -->",
                                          "
[indent]",
                                          "[/indent]
",
                                          "class='quotetop'",
                                          "class='quotemain'",
                                          "class='codetop'",
                                          "class='codemain'" ),
                                   array( $row[1],
                                          $row[9],
                                          //Laika form?ts
                                          date( "H:i, j.m.Y", $row[5] ),
                                          $row[8],
                                          $row[10],
                                          $cfg['forum_path'],
                                          $row[0],
                                          $cfg['forum_mape'] ."/style_emoticons/default",
                                          $row[7],
                                          "<blockquote>",
                                          "</blockquote>",
                                          "style='background: #E4EAF2; border: 1px dotted #000; border-bottom: 0; border-left: 4px solid #8394B2; color: #000; font-weight: bold; font-size: 10px; margin: 8px auto 0 auto; padding: 3px;'",
                                          "style='background: #FAFCFE; border: 1px dotted #000; border-left: 4px solid #8394B2; border-top: 0; color: #465584; padding: 4px; margin: 0 auto 8px auto;'",
                                          "style='background: #FDDBCC; color: #000; font-weight: bold; margin: 0 auto 0 auto; padding: 3px; width: 98%;'",
                                          "style='background: #FAFCFE; border: 1px dotted #000; color: #465584; font-family: Courier, Courier New, Verdana, Arial; margin: 0 auto 0 auto; padding: 2px; width: 98%;'" ),
                                   $sTemplate );

           if ( $cfg['debug'] != "true" ) {
               echo $sParsed;
           }

           $iCurrent++;
        }
   }

   mysql_free_result( $query );
}

//echo "<hr><center><div class='pagination'>";
if ( $cfg['page_select'] == "true" ) {
   if ( $_GET['pg'] == "1" || $_GET['pg'] == "" ) {
       echo "<span class='disabled'>«</span>";

   } else {

 echo "<a href='?pg=". ( $_GET['pg'] - 1 ) ."'>«</a>";	
   }


   for ( $i = 0; $i < $iNews / $cfg['per_page']; $i++ ) {
       if ( $i == $_GET['pg'] - 1 || ( $i == 0 && $_GET['pg'] == "" ) ) {
           echo "<span class='current'>". ( $i + 1 ) ."</span>";
       } else {
           echo "<a href='?pg=". ( $i + 1 ) ."'>". ( $i + 1 ) ."</a>"; //NEIZVEELEETAA KATRA


       }
   }

   if ( $_GET['pg'] == $i ) {
echo "<span class='disabled'>»</span>";//PEEDEEJAA KAD TALAK NEVAR
   } else if ( $i > 1 && $_GET['pg'] == "" ) {
       echo "<a href='?pg=". ( $_GET['pg'] + 2 ) ."'>»</a>";


   } else if ( $i <= 1 && $_GET['pg'] == "" ) {
       echo "<span class='disabled'>»</span>";//tik 1 lapa kad ir
   } else {
	 echo "<a href='?pg=". ( $_GET['pg'] + 1 ) ."'>»</a>";	
   }
}
//echo "</div></center>";

?>

Ceru kad kādam noderēs.

Link to comment
Share on other sites

×
×
  • Create New...