TimX
Bosh sahifaga maqola chiqarish kodi. Kim xatolikni ajratib bera oladi?
  1. <?php
  2.  
  3. echo '<div class="phdr"><b>Yangi maqolalar</b></div>';
  4. $kmess = '10';
  5.  
  6. $total = $db->query("SELECT COUNT(*) FROM `library_texts` WHERE `time` AND `premod` = 1")->fetchColumn();
  7. $page = $page >= ceil($total / $kmess) ? ceil($total / $kmess) : $page;
  8. $start = $page == 1 ? 0 : ($page - 1) * $kmess;
  9.  
  10. $req = $db->query(
  11. "SELECT `id`, `name`, `time`, `uploader`, `uploader_id`, `count_views`, `comments`, `comm_count`, `cat_id`, `announce` FROM `library_texts` WHERE `premod` = 1
  12. ORDER BY `time` DESC
  13. LIMIT " . $start . ', ' . $user->config->kmess
  14. );
  15.  
  16. 'pagination' => $tools->displayPagination('?act=new&amp;', $start, $total, $user->config->kmess),
  17. 'total' => $total,
  18. 'list' =>
  19. static function () use ($req, $tools, $config, $db) {
  20. while ($res = $req->fetch()) {
  21. $res['cover'] = file_exists(UPLOAD_PATH . '/library/images/small/' . $res['id'] . '.png');
  22.  
  23. $obj = new Hashtags($res['id']);
  24. $res['tags'] = $obj->getAllStatTags() ? $obj->getAllStatTags(1) : null;
  25.  
  26. $rate = new Rating($res['id']);
  27. $res['ratingView'] = $rate->viewRate(1);
  28.  
  29. $uploader = $res['uploader_id']
  30. ? '<a href="' . $config['homeurl'] . '/profile/?user=' . $res['uploader_id'] . '">' . $tools->checkout($res['uploader']) . '</a>'
  31. : $tools->checkout($res['uploader']);
  32. $res['who'] = $uploader . ' (' . $tools->displayDate($res['time']) . ')';
  33.  
  34. $res['name'] = $tools->checkout($res['name']);
  35. $res['announce'] = $tools->checkout($res['announce'], 0, 0);
  36.  
  37. $catalog = $db->query('SELECT `id`, `name` FROM `library_cats` WHERE `id` = ' . $res['cat_id'] . ' LIMIT 1')->fetch();
  38. $res['catalog_name'] = $tools->checkout($catalog['name']);
  39.  
  40. yield $res;
  41. }
  42. },
  43. ]
  44. );
  45.  
  46. ?>