Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if( !defined( 'DATALIFEENGINE' ) ) {
- die( "Hacking attempt!" );
- }
- if( $_GET['mode'] != 'views' and $_GET['mode'] != 'comments' and $_GET['mode'] != 'rating' ) {
- msgbox( $lang['all_err_1'], $lang['news_err_27'] );
- }
- include ENGINE_DIR . '/data/top100.config.php';
- include ENGINE_DIR . '/api/api.class.php';
- $top100_config['news_num'] = 10;
- $top100_config['category'] = '1,2,3,4,5,6,7';
- /*
- $top100_config['title_num'] = 'a';
- $top100_config['title_post'] = 'b';
- $top100_config['title_name'] = 'c';
- $top100_config['title_views_head'] = 'd';
- $top100_config['title_views'] = 'e';
- $top100_config['title_comments'] = 'f';
- $top100_config['title_rating'] = 'g';
- */
- if( $top100_config['category'] != 0 ) {
- $category_true = "AND category IN (" . $top100_config['category'] . ")";
- } else {
- $category_true = "";
- }
- if( $_GET['mode'] == 'views' ) {
- $cache = $dle_api->load_from_cache( "top100views", 3600, $tpl->result['content'] );
- if( $cache === false ) {
- $sql_result = $db->query( "SELECT p.id, p.title, p.category, p.alt_name, p.xfields, e.news_read FROM " . PREFIX . "_post as p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE approve=1 " . $category_true . " ORDER BY e.news_read DESC LIMIT " . $top100_config['news_num'] );
- $top100 = <<<HTML
- <thead>
- <tr>
- <td align="center">{$top100_config['title_num']}</td>
- <td align="center">{$top100_config['title_post']}</td>
- <td align="center">{$top100_config['title_name']}</td>
- <td align="center">{$top100_config['title_views_head']}</td>
- </tr>
- </thead>
- HTML;
- $top100 .= <<<HTML
- <tbody>
- HTML;
- $i=1;
- while ( $row = $db->get_row($sql_result) ) {
- $row['category'] = intval( $row['category'] );
- if( $config['allow_alt_url'] ) {
- if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
- if( $row['category'] and $config['seo_type'] == 2 ) {
- $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
- } else {
- $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
- }
- $xfields = xfieldsdataload( $row['xfields'] );
- $Link = isset($xfields['image']) ? $xfields['image'] : "null";
- $row['title'] = strip_tags( stripslashes( $row['title'] ) );
- $row['news_read'] = intval( $row['news_read'] );
- $top100 .='';
- if( $row['news_read'] != 0 ) {
- $top100 .= <<<HTML
- <tr>
- <td align="center"> {$i} </td>
- <td>Вывод дополнительного поля {$Link}</td>
- <td><a href="{$full_link}" title="{$row['title']}">{$row['title']}</td>
- <td align="center">{$row['news_read']}</td>
- </tr>
- HTML;
- $i++;
- }
- }
- $db->free();
- $top100 .= <<<HTML
- </tbody>
- HTML;
- $tpl->load_template( 'top100.tpl' );
- $tpl->set( '{title}', $top100_config['title_views'] );
- $tpl->set( '{title1}', $top100_config['title_comments'] );
- $tpl->set( '{title2}', $top100_config['title_rating'] );
- $tpl->set( '{top100}', $top100 );
- $tpl->compile( 'content' );
- $tpl->clear();
- $dle_api->save_to_cache( "top100views", $tpl->result['content'] );
- } else {
- var_dump($cache);
- }
- }
- if( $_GET['mode'] == 'comments' ) {
- $cache = $dle_api->load_from_cache( "top100comments", 3600, $tpl->result['content'] );
- if( $cache === false ) {
- $sql_result = $db->query( "SELECT id, title, category, alt_name, comm_num FROM " . PREFIX . "_post WHERE approve=1 " . $category_true . " ORDER BY comm_num DESC LIMIT " . $top100_config['news_num'] );
- $top100 = <<<HTML
- <thead>
- <tr>
- <td align="center">{$top100_config['title_num']}</td>
- <td align="center">{$top100_config['title_post']}</td>
- <td align="center">{$top100_config['title_name']}</td>
- <td align="center">{$top100_config['title_comments_head']}</td>
- </tr>
- </thead>
- HTML;
- $top100 .= <<<HTML
- <tbody>
- HTML;
- $i=1;
- while ( $row = $db->get_row($sql_result) ) {
- $row['category'] = intval( $row['category'] );
- if( $config['allow_alt_url'] ) {
- if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
- if( $row['category'] and $config['seo_type'] == 2 ) {
- $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
- } else {
- $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
- }
- $row['title'] = strip_tags( stripslashes( $row['title'] ) );
- $row['comm_num'] = intval( $row['comm_num'] );
- if( $row['comm_num'] != 0 ) {
- $top100 .= <<<HTML
- <tr>
- <td align="center"> {$i} </td>
- <td><a href="{$full_link}" title="{$row['title']}"><strong>{$row['title']}</strong></a></td>
- <td align="center">{$row['comm_num']}</td>
- </tr>
- HTML;
- $i++;
- }
- }
- $db->free();
- $top100 .= <<<HTML
- </tbody>
- HTML;
- $tpl->load_template( 'top100.tpl' );
- $tpl->set( '{title}', $top100_config['title_views'] );
- $tpl->set( '{title1}', $top100_config['title_comments'] );
- $tpl->set( '{title2}', $top100_config['title_rating'] );
- $tpl->set( '{top100}', $top100 );
- $tpl->compile( 'content' );
- $tpl->clear();
- $dle_api->save_to_cache ( "top100comments", $tpl->result['content'] );
- } else {
- var_dump($cache);
- }
- }
- if( $_GET['mode'] == 'rating' ) {
- $cache = $dle_api->load_from_cache ( "top100rating", 3600, $tpl->result['content'] );
- if( $cache === false ) {
- $sql_result = $db->query( "SELECT p.id, p.title, p.category, p.alt_name, e.allow_rate, e.rating, '1' as flag FROM " . PREFIX . "_post as p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE approve=1 " . $category_true . " ORDER BY e.rating DESC LIMIT " . $top100_config['news_num'] );
- $top100 = <<<HTML
- <thead>
- <tr>
- <td align="center">$top100_config[title_num]</td>
- <td align="center">$top100_config[title_name]</td>
- <td align="center">$top100_config[title_rating_head]</td>
- </tr>
- </thead>
- HTML;
- $top100 .= <<<HTML
- <tbody>
- HTML;
- $i=1;
- while ( $row = $db->get_row($sql_result) ) {
- $row['category'] = intval( $row['category'] );
- if( $config['allow_alt_url'] ) {
- if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
- if( $row['category'] and $config['seo_type'] == 2 ) {
- $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
- } else {
- $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
- }
- } else {
- $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
- }
- $row['title'] = strip_tags( stripslashes( $row['title'] ) );
- $row['rating'] = intval( $row['rating'] );
- if( $row['rating'] != 0 ) {
- $top100 .= <<<HTML
- <tr>
- <td align="center"> $i </td>
- <td><a href="$full_link" title=""><strong>$row[title]</strong></a></td>
- <td align="center">$row[rating]</td>
- </tr>
- HTML;
- $i++;
- }
- }
- $db->free();
- $top100 .= <<<HTML
- </tbody>
- HTML;
- $tpl->load_template( 'top100.tpl' );
- $tpl->set( '{title}', $top100_config['title_views'] );
- $tpl->set( '{title1}', $top100_config['title_comments'] );
- $tpl->set( '{title2}', $top100_config['title_rating'] );
- $tpl->set( '{top100}', $top100 );
- $tpl->compile( 'content' );
- $tpl->clear();
- $dle_api->save_to_cache( "top100rating", $tpl->result['content'] );
- } else {
- var_dump($cache);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment