function _HCM_filelist($cesta = "", $velikosti = false) { $result = ""; $cesta = _indexroot . $cesta; $velikosti = _boolean($velikosti); if (mb_substr($cesta, -1, 1) != "/") { $cesta .= "/"; } if (@file_exists($cesta) and @is_dir($cesta)) { $handle = @opendir($cesta); while (false !== ($item = @readdir($handle))) { if (@is_dir($cesta . $item) or $item == "." or $item == "..") { continue; } $items[] = $item; } natsort($items); $result = "<ul>\n"; foreach ($items as $item) { $result .= "<li>"; $result .= "<a href='" . $cesta . _htmlStr($item) . "' target='_blank'>" . $item . "</a>"; if ($velikosti) { $result .= " (" . round(@filesize($cesta . $item) / 1024) . "kB)"; } $result .= "</li>\n"; } $result .= "</ul>\n"; @closedir($handle); } return $result; }
function _HCM_mailform($adresa = "", $priloha = false, $predmet = null) { // priprava $result = ""; $_SESSION[_sessionprefix . 'hcm_' . SL::$hcmUid . '_mail_receiver'] = @implode(",", _arrayRemoveValue(@explode(";", trim($adresa)), "")); if (_boolean($priloha)) { $rfile = array($GLOBALS['_lang']['hcm.mailform.att'], "<input type='file' name='att' />"); $att = true; } else { $rfile = array(''); $att = false; } if (isset($predmet)) { $rsubject = " value='" . _htmlStr($predmet) . "'"; } else { $rsubject = ""; } $rcaptcha = _captchaInit(); // zprava $msg = ''; if (isset($_GET['hcm_mr_' . SL::$hcmUid])) { switch ($_GET['hcm_mr_' . SL::$hcmUid]) { case 1: $msg = _formMessage(1, $GLOBALS['_lang']['hcm.mailform.msg.done']); break; case 2: $msg = _formMessage(2, $GLOBALS['_lang']['hcm.mailform.msg.failure']); break; case 3: $msg = _formMessage(3, $GLOBALS['_lang']['hcm.mailform.msg.failure2']); break; case 4: $msg = _formMessage(3, $GLOBALS['_lang']['xsrf.msg']); break; } } // predvyplneni odesilatele if (_loginindicator) { $sender = _loginemail; } else { $sender = "@"; } $result .= "<div class='anchor'><a name='hcm_mform_" . SL::$hcmUid . "'></a></div>\n" . $msg . _formOutput("mform" . SL::$hcmUid, _indexroot . "remote/hcm/mform.php?_return=" . urlencode(_indexOutput_url) . ($att ? "' enctype='multipart/form-data" : ''), array(array($GLOBALS['_lang']['hcm.mailform.sender'], "<input type='text' class='inputsmall' name='sender' value='" . $sender . "' /><input type='hidden' name='fid' value='" . SL::$hcmUid . "' />"), array($GLOBALS['_lang']['posts.subject'], "<input type='text' class='inputsmall' name='subject'" . $rsubject . " />"), $rcaptcha, array($GLOBALS['_lang']['hcm.mailform.text'], "<textarea class='areasmall' name='text' rows='9' cols='33'></textarea>", true), $rfile), array("text", "sender"), $GLOBALS['_lang']['hcm.mailform.send']); return $result; }
function _HCM_player($soubor = "", $sirka = null, $vyska = null, $autoplay = false) { // prednastavene hodnoty $extension = pathinfo($soubor); if (isset($extension['extension'])) { $extension = $extension['extension']; } if ($extension == "mp3") { $defvyska = "19"; } else { $defvyska = "240"; } $defsirka = "320"; // nacteni parametru $soubor = _htmlStr($soubor); if (!_isAbsolutePath($soubor)) { $soubor = _url . "/" . $soubor; } if (!isset($sirka)) { $sirka = $defsirka; } else { $sirka = intval($sirka); } if (!isset($vyska)) { $vyska = $defvyska; } else { $vyska = intval($vyska); } $autoplay = _booleanStr(_boolean($autoplay)); // sestaveni kodu return ' <div id="player_' . SL::$hcmUid . '"><div class="message2">' . $GLOBALS['_lang']['hcm.player.alt'] . '</div></div> <script type="text/javascript"> // <![CDATA[ var so = new SWFObject("' . _indexroot . 'remote/hcm/player.swf", "player_embed_' . SL::$hcmUid . '", "' . $sirka . '", "' . $vyska . '", "9", "#000000"); so.addParam("allowfullscreen","true"); so.addVariable("file", "' . $soubor . '"); so.addVariable("link", "' . $soubor . '"); so.addVariable("autostart", "' . $autoplay . '"); so.write("player_' . SL::$hcmUid . '"); // ]]> </script> '; }
function _HCM_php($kod = "", $ze_souboru = false) { if (_boolean($ze_souboru)) { // ze souboru $soubor = _indexroot . $kod; if (@file_exists($soubor)) { $_params = func_get_args(); array_slice($_params, 2); $output = ''; $include = (include $soubor); if (is_string($include)) { return $include; } else { return $output; } } } else { // kod return _evalBox($kod); } }
function _HCM_linkroot($id = null, $text = null, $nove_okno = false) { $is_id = is_numeric($id); if ($is_id) { $id = intval($id); } else { $id = DB::val($id); } $query = DB::query("SELECT title,title_seo FROM `" . _mysql_prefix . "-root` WHERE " . ($is_id ? 'id' : 'title_seo') . "=" . $id); if (isset($nove_okno) and _boolean($nove_okno)) { $target = " target='_blank'"; } else { $target = ""; } if (DB::size($query) != 0) { $query = DB::row($query); if (isset($text) and $text != "") { $query['title'] = $text; } return "<a href='" . _linkRoot($id, $query['title_seo']) . "'" . $target . ">" . $query['title'] . "</a>"; } }
function _HCM_gallery($cesta = "", $rozmery = null, $strankovani = null, $lightbox = 1) { // priprava $result = ""; $cesta = _indexroot . $cesta; $cesta_noroot = $cesta; if (mb_substr($cesta, -1, 1) != "/") { $cesta .= "/"; } if (mb_substr($cesta_noroot, -1, 1) != "/") { $cesta_noroot .= "/"; } if (isset($strankovani) and $strankovani > 0) { $strankovat = true; $strankovani = intval($strankovani); if ($strankovani <= 0) { $strankovani = 1; } } else { $strankovat = false; } $lightbox = _boolean($lightbox); if (isset($rozmery)) { $rozmery = explode('/', $rozmery); if (sizeof($rozmery) === 2) { // sirka i vyska $x = intval($rozmery[0]); $y = intval($rozmery[1]); } else { // pouze vyska $x = null; $y = intval($rozmery[0]); } } else { // neuvedeno $x = null; $y = 128; } if (@file_exists($cesta) and @is_dir($cesta)) { $handle = @opendir($cesta); // nacteni polozek $items = array(); while (false !== ($item = @readdir($handle))) { $ext = pathinfo($item); if (isset($ext['extension'])) { $ext = mb_strtolower($ext['extension']); } else { $ext = ""; } if (@is_dir($item) or $item == "." or $item == ".." or !in_array($ext, SL::$imageExt)) { continue; } $items[] = $item; } @closedir($handle); natsort($items); // priprava strankovani if ($strankovat) { $count = count($items); $paging = _resultPaging(_indexOutput_url, $strankovani, $count, "", "#hcm_gal" . SL::$hcmUid, "hcm_gal" . SL::$hcmUid . "p"); } // vypis $result = "<div class='anchor'><a name='hcm_gal" . SL::$hcmUid . "'></a></div>\n<div class='gallery'>\n"; $counter = 0; foreach ($items as $item) { if ($strankovat and $counter > $paging[6]) { break; } if (!$strankovat or $strankovat and _resultPagingIsItemInRange($paging, $counter)) { $thumb = _pictureThumb($cesta_noroot . $item, array('x' => $x, 'y' => $y)); $result .= "<a href='" . $cesta . _htmlStr($item) . "' target='_blank'" . ($lightbox ? " class='lightbox' data-fancybox-group='lb_hcm" . SL::$hcmUid . "'" : '') . "><img src='" . $thumb . "' alt='" . $item . "' /></a>\n"; } $counter++; } $result .= "</div>\n"; if ($strankovat) { $result .= $paging[0]; } } return $result; }
define('_session_old_id', session_id()); session_regenerate_id(true); } } $result = 0; // pole konstant opravneni $rights_array = _getRightsArray(); // pouziti cookie persistentniho prihlaseni, pokud existuje $persistent_cookie_found = false; if (!$disabled && isset($_COOKIE[_sessionprefix . "persistent_key"])) { // nacist data $persistent_cookie = $_COOKIE[_sessionprefix . "persistent_key"]; $persistent_cookie = explode('$', $persistent_cookie); if (count($persistent_cookie) == 3) { $persistent_cookie[0] = intval($persistent_cookie[0]); $persistent_cookie[1] = _boolean($persistent_cookie[1]); $persistent_cookie_found = true; } } // kontrola existence session if (!$disabled && ($persistent_cookie_found or isset($_SESSION[_sessionprefix . "user"]) and isset($_SESSION[_sessionprefix . "password"]) and isset($_SESSION[_sessionprefix . "ip"]))) { // pouziti cookie pro nastaveni dat session (pokud neexistuji) $persistent_cookie_used = false; $persistent_cookie_bad = false; if ($persistent_cookie_found and !(isset($_SESSION[_sessionprefix . "user"]) and isset($_SESSION[_sessionprefix . "password"]) and isset($_SESSION[_sessionprefix . "ip"])) and _iplogCheck(1)) { $persistent_cookie_bad = true; $uquery = DB::query("SELECT * FROM `" . _mysql_prefix . "-users` WHERE id=" . $persistent_cookie[0]); if (DB::size($uquery) != 0) { $uquery = DB::row($uquery); $persistent_cookie_used = true; if ($persistent_cookie[2] == _md5HMAC($uquery['password'] . '$' . $uquery['email'], $persistent_cookie[1] ? _userip : _sessionprefix)) {
/** * Vytvoreni vypisu prispevku * * Type Popis Vars * 1 komentare sekce zamknute komentare 1/0 * 2 komentare článku zamknute komentare 1/0 * 3 prispevky v knize [polozek na stranu, povoleno prispivani 1/0, zamknuto 1/0] * 5 temata ve foru [polozek na stranu, povoleno prispivani 1/0, zamknuto 1/0] * 6 odpovedi na tema [polozek na stranu, povoleno prispivani 1/0, zamknuto 1/0, id tematu] * 7 vypis vzkazu [zamknuto 1/0] * 8 vypis pluginpostu [polozek na stranu, povoleno prispivani 1/0, zamknuto 1/0, plugin flag, radit sestupne 1/0, [titulek / null]] * * @param int $type typ prispevku * @param int $home id polozky asociovane s komentari * @param mixed $vars promenna nastaveni podle typu * @param bool $force_locked vynutit zamknuty stav * @param string|null $url vlastni url nebo null (= automaticky) * @return string */ function _postsOutput($type, $home, $vars, $force_locked = false, $url = null) { global $_lang; /* --- typ --- */ // vychozi hodnoty $desc = "DESC "; $ordercol = 'id'; $countcond = "type=" . $type . " AND xhome=-1 AND home=" . $home; $locked_textid = ''; $autolast = false; $postlink = false; $pluginflag = null; // url if (!isset($url)) { $url = _indexOutput_url; } $url_html = _htmlStr($url); switch ($type) { // komentare v sekci case 1: $posttype = 1; $xhome = -1; $subclass = "comments"; $title = $_lang['posts.comments']; $addlink = $_lang['posts.addcomment']; $nopostsmessage = $_lang['posts.nocomments']; $postsperpage = _commentsperpage; $canpost = _loginright_postcomments; $locked = _boolean($vars); $replynote = true; break; // komentare u clanku // komentare u clanku case 2: $posttype = 2; $xhome = -1; $subclass = "comments"; $title = $_lang['posts.comments']; $addlink = $_lang['posts.addcomment']; $nopostsmessage = $_lang['posts.nocomments']; $postsperpage = _commentsperpage; $canpost = _loginright_postcomments; $locked = _boolean($vars); $replynote = true; break; // prispevky v knize // prispevky v knize case 3: $posttype = 3; $xhome = -1; $subclass = "book"; $title = null; $addlink = $_lang['posts.addpost']; $nopostsmessage = $_lang['posts.noposts']; $postsperpage = $vars[0]; $canpost = $vars[1]; $locked = _boolean($vars[2]); $replynote = true; break; // temata ve foru // temata ve foru case 5: $posttype = 5; $xhome = -1; $subclass = "book"; $title = null; $addlink = $_lang['posts.addtopic']; $nopostsmessage = $_lang['posts.notopics']; $postsperpage = $vars[0]; $canpost = $vars[1]; $locked = _boolean($vars[2]); $replynote = true; $ordercol = 'bumptime'; $locked_textid = '3'; break; // odpovedi v tematu // odpovedi v tematu case 6: $posttype = 5; $xhome = $vars[3]; $subclass = "book"; $title = null; $addlink = $_lang['posts.addanswer']; $nopostsmessage = $_lang['posts.noanswers']; $postsperpage = $vars[0]; $canpost = $vars[1]; $locked = _boolean($vars[2]); $replynote = false; $desc = ""; $countcond = "type=5 AND xhome=" . $xhome . " AND home=" . $home; $autolast = isset($_GET['autolast']); $postlink = true; break; // odpovedi v konverzaci // odpovedi v konverzaci case 7: $posttype = 6; $xhome = null; $subclass = "book"; $title = null; $addlink = $_lang['posts.addanswer']; $nopostsmessage = $_lang['posts.noanswers']; $postsperpage = _messagesperpage; $canpost = true; $locked = _boolean($vars[0]); $replynote = false; $desc = ""; $countcond = "type=6 AND home=" . $home; $locked_textid = '4'; $autolast = true; break; // plugin posty // plugin posty case 8: $posttype = 7; $xhome = -1; $subclass = "book"; $title = isset($vars[5]) ? $vars[5] : null; $addlink = $_lang['posts.addpost']; $nopostsmessage = $_lang['posts.noposts']; $postsperpage = $vars[0]; $canpost = $vars[1]; $locked = _boolean($vars[2]); $replynote = true; $pluginflag = $vars[3]; $countcond .= " AND flag=" . $pluginflag; if (!$vars[4]) { $desc = ''; } break; } // vynutit uzamceni parametrem if ($force_locked) { $locked = true; } // extend $callback = null; _extend('call', 'posts.output', array('type' => $type, 'home' => $home, 'xhome' => $xhome, 'vars' => $vars, 'post_type' => $posttype, 'plugin_flag' => $pluginflag, 'canpost' => &$canpost, 'locked' => &$locked, 'autolast' => &$autolast, 'post_link' => &$postlink, 'posts_per_page' => &$postsperpage, 'sql_desc' => &$desc, 'sql_ordercol' => &$ordercol, 'sql_countcond' => &$countcond, 'callback' => &$callback)); /* --- vystup --- */ $output = "\n <div class='anchor'><a name='posts'></a></div>\n <div class='posts-" . $subclass . "'>\n "; if ($title != null) { $output .= "<h2>" . $title . _linkRss($home, $posttype) . "</h2>\n"; } $output .= "<div class='posts-form' id='post-form'>\n"; /* --- priprava strankovani --- */ $paging = _resultPaging($url_html, $postsperpage, "posts", $countcond, "#posts", null, $autolast); /* --- zprava --- */ if (isset($_GET['r'])) { switch ($_GET['r']) { case 0: $output .= _formMessage(2, $_lang['posts.failed']); break; case 1: $output .= _formMessage(1, $_lang[$type != 5 ? 'posts.added' : 'posts.topicadded']); break; case 2: $output .= _formMessage(2, str_replace("*postsendexpire*", _postsendexpire, $_lang['misc.requestlimit'])); break; case 3: $output .= _formMessage(2, $_lang['posts.guestnamedenied']); break; case 4: $output .= _formMessage(2, $_lang['xsrf.msg']); break; } } /* --- formular nebo odkaz na pridani --- */ if (!$locked and (isset($_GET['addpost']) or isset($_GET['replyto']))) { // nacteni cisla prispevku pro odpoved if ($xhome == -1) { if (isset($_GET['replyto']) and $_GET['replyto'] != -1) { $reply = intval($_GET['replyto']); if ($replynote) { $output .= "<p>" . $_lang['posts.replynote'] . " (<a href='" . $url_html . "#posts'>" . $_lang['global.cancel'] . "</a>).</p>"; } } else { $reply = -1; } } else { $reply = $xhome; } // formular nebo prihlaseni if ($canpost) { $form = _uniForm("postform", array('posttype' => $type, 'pluginflag' => $pluginflag, 'posttarget' => $home, 'xhome' => $reply, 'url' => $url)); $output .= $form[0]; } else { $loginform = _uniForm("login", array(), true); $output .= "<p>" . $_lang['posts.loginrequired'] . "</p>" . $loginform[0]; } } else { if (!$locked) { $output .= "<a href='" . _addGetToLink($url_html, "addpost&page=" . $paging[2]) . "#posts'><strong>" . $addlink . " ></strong></a>"; } else { $output .= "<img src='" . _templateImage("icons/lock.png") . "' alt='stop' class='icon' /> <strong>" . $_lang['posts.locked' . $locked_textid] . "</strong>"; } } $output .= "</div>\n<div class='hr'><hr /></div>\n\n"; /* --- vypis --- */ if (_pagingmode == 1 or _pagingmode == 2) { $output .= $paging[0]; } // zaklad query if ($type == 5) { $sql = "SELECT id,author,guest,subject,time,ip,locked,bumptime,sticky,(SELECT COUNT(id) FROM `" . _mysql_prefix . "-posts` WHERE type=5 AND xhome=post.id) AS answer_count"; } else { $sql = "SELECT id,xhome,subject,text,author,guest,time,ip" . _extend('buffer', 'posts.columns'); } $sql .= " FROM `" . _mysql_prefix . "-posts` AS post"; // podminky a razeni $sql .= " WHERE post.type=" . $posttype . (isset($xhome) ? " AND post.xhome=" . $xhome : '') . " AND post.home=" . $home . (isset($pluginflag) ? " AND post.flag=" . $pluginflag : ''); $sql .= " ORDER BY " . ($type == 5 ? 'sticky DESC,' : '') . $ordercol . ' ' . $desc . $paging[1]; // dotaz $query = DB::query($sql); unset($sql); // nacteni prispevku do pole $items = array(); if ($type == 5) { $item_ids_with_answers = array(); } while ($item = DB::row($query)) { $items[$item['id']] = $item; if ($type == 5 && $item['answer_count'] != 0) { $item_ids_with_answers[] = $item['id']; } } // uvolneni dotazu DB::free($query); if ($type == 5) { // posledni prispevek (pro vypis temat) if (!empty($item_ids_with_answers)) { $topicextra = DB::query("SELECT * FROM (SELECT id,xhome,author,guest FROM `" . _mysql_prefix . "-posts` AS reply WHERE type=5 AND home=" . $home . " AND xhome IN(" . implode(',', $item_ids_with_answers) . ") ORDER BY reply.id DESC) AS replies GROUP BY xhome"); while ($item = DB::row($topicextra)) { if (!isset($items[$item['xhome']])) { if (_dev) { trigger_error('Nenalezen domovsky prispevek pro odpoved #' . $item['id'], E_USER_WARNING); } continue; } $items[$item['xhome']]['_lastpost'] = $item; } } } elseif (!empty($items)) { // odpovedi (pro komentare) $answers = DB::query("SELECT id,xhome,text,author,guest,time,ip FROM `" . _mysql_prefix . "-posts` WHERE type=" . $posttype . " AND home=" . $home . (isset($pluginflag) ? " AND flag=" . $pluginflag : '') . " AND xhome IN(" . implode(',', array_keys($items)) . ") ORDER BY id"); while ($item = DB::row($answers)) { if (!isset($items[$item['xhome']])) { if (_dev) { trigger_error('Nenalezen domovsky prispevek pro odpoved #' . $item['id'], E_USER_WARNING); } continue; } if (!isset($items[$item['xhome']]['_answers'])) { $items[$item['xhome']]['_answers'] = array(); } $items[$item['xhome']]['_answers'][] = $item; } DB::free($answers); } // vypis if (!empty($items)) { // vypis prispevku nebo temat if ($type != 5) { $hl = true; foreach ($items as $item) { // nacteni autora if ($item['guest'] == "") { $author = _linkUser($item['author'], "post-author"); } else { $author = "<span class='post-author-guest' title='" . _showIP($item['ip']) . "'>" . $item['guest'] . "</span>"; } // odkazy pro spravu $post_access = _postAccess($item); if ($type < 6 or $type > 7 or $post_access) { $actlinks = " <span class='post-actions'>"; if (($type < 6 or $type > 7) && !$locked) { $actlinks .= "<a href='" . _addGetToLink($url_html, "replyto=" . $item['id']) . "#posts'>" . $_lang['posts.reply'] . "</a>"; } if ($post_access) { $actlinks .= (($type < 6 or $type > 7) ? " " : '') . "<a href='index.php?m=editpost&id=" . $item['id'] . "'>" . $_lang['global.edit'] . "</a>"; } $actlinks .= "</span>"; } else { $actlinks = ""; } // avatar if (_show_avatars) { $avatar = _getAvatar($item['author']); } else { $avatar = null; } // prispevek $hl = !$hl; _extend('call', 'posts.post', array('item' => &$item, 'avatar' => &$avatar, 'type' => $type)); if (null === $callback) { $output .= "<div id='post-" . $item['id'] . "' class='post" . ($hl ? ' post-hl' : '') . (isset($avatar) ? ' post-withavatar' : '') . "'><div class='post-head'>" . $author; if ($type < 6 || $type > 7) { $output .= ", <span class='post-subject'>" . $item['subject'] . "</span> "; } $output .= "<span class='post-info'>(" . _formatTime($item['time']) . ")</span>" . $actlinks . ($postlink ? "<a class='post-postlink' href='" . _addGetToLink($url_html, 'page=' . $paging[2]) . "#post-" . $item['id'] . "'><span>#" . str_pad($item['id'], 6, '0', STR_PAD_LEFT) . "</span></a>" : '') . "</div><div class='post-body" . (isset($avatar) ? ' post-body-withavatar' : '') . "'>" . $avatar . '<div class="post-body-text">' . _parsePost($item['text']) . "</div></div></div>\n"; } else { $output .= call_user_func($callback, array('item' => $item, 'avatar' => $avatar, 'author' => $author, 'actlinks' => $actlinks, 'page' => $paging[2], 'postlink' => $postlink)); } // odpovedi if (($type < 6 || $type > 7) && isset($item['_answers'])) { foreach ($item['_answers'] as $answer) { // jmeno autora if ($answer['guest'] == "") { $author = _linkUser($answer['author'], "post-author"); } else { $author = "<span class='post-author-guest' title='" . _showIP($answer['ip']) . "'>" . $answer['guest'] . "</span>"; } // odkazy pro spravu if (_postAccess($answer)) { $actlinks = " <span class='post-actions'><a href='index.php?m=editpost&id=" . $answer['id'] . "'>" . $_lang['global.edit'] . "</a></span>"; } else { $actlinks = ""; } // avatar if (_show_avatars) { $avatar = _getAvatar($answer['author']); } else { $avatar = null; } _extend('call', 'posts.post', array('item' => &$answer, 'avatar' => &$avatar, 'type' => $type)); if (null === $callback) { $output .= "<div id='post-" . $answer['id'] . "' class='post-answer" . (isset($avatar) ? ' post-answer-withavatar' : '') . "'><div class='post-head'>" . $author . " " . $_lang['posts.replied'] . " <span class='post-info'>(" . _formatTime($answer['time']) . ")</span>" . $actlinks . "</div><div class='post-body" . (isset($avatar) ? ' post-body-withavatar' : '') . "'>" . $avatar . '<div class="post-body-text">' . _parsePost($answer['text']) . "</div></div></div>\n"; } else { $output .= call_user_func($callback, array('item' => $answer, 'avatar' => $avatar, 'author' => $author, 'actlinks' => $actlinks, 'page' => $paging[2], 'postlink' => $postlink)); } } } } if (_pagingmode == 2 or _pagingmode == 3) { $output .= "<br />" . $paging[0]; } } else { // tabulka s tematy $hl = false; $output .= "\n<table class='topic-table'>\n<thead><tr><td colspan='2'><strong>" . $_lang['posts.topic'] . "</strong></td><td><strong>" . $_lang['global.answersnum'] . "</strong></td><td><strong>" . $_lang['global.lastanswer'] . "</strong></td></tr></thead>\n<tbody>\n"; foreach ($items as $item) { // nacteni autora if ($item['guest'] == "") { $author = _linkUser($item['author'], "post-author", false, false, 16); } else { $author = "<span class='post-author-guest' title='" . _showIP($item['ip']) . "'>" . _cutStr($item['guest'], 16) . "</span>"; } // nacteni jmena autora posledniho prispevku if (isset($item['_lastpost'])) { if ($item['_lastpost']['author'] != -1) { $lastpost = _linkUser($item['_lastpost']['author'], "post-author", false, false, 16); } else { $lastpost = "<span class='post-author-guest'>" . _cutStr($item['_lastpost']['guest'], 16) . "</span>"; } } else { $lastpost = "-"; } // vyber ikony if ($item['sticky']) { $icon = 'sticky'; } elseif ($item['locked']) { $icon = 'locked'; } elseif ($item['answer_count'] == 0) { $icon = 'new'; } elseif ($item['answer_count'] < _topic_hot_ratio) { $icon = 'normal'; } else { $icon = 'hot'; } // mini strankovani $tpages = ''; $tpages_num = ceil($item['answer_count'] / _commentsperpage); if ($tpages_num == 0) { $tpages_num = 1; } if ($tpages_num > 1) { $tpages .= '<span class=\'topic-pages\'>'; for ($i = 1; $i <= 3 && $i <= $tpages_num; ++$i) { $tpages .= "<a href='index.php?m=topic&id=" . $item['id'] . "&page=" . $i . "#posts'>" . $i . '</a>'; } if ($tpages_num > 3) { $tpages .= "<a href='index.php?m=topic&id=" . $item['id'] . "&page=" . $tpages_num . "'>" . $tpages_num . ' →</a>'; } $tpages .= '</span>'; } // vystup radku $output .= "<tr class='topic-" . $icon . ($hl ? ' topic-hl' : '') . "'><td class='topic-icon-cell'><a href='index.php?m=topic&id=" . $item['id'] . "'><img src='" . _templateImage('icons/topic-' . $icon . '.png') . "' alt='" . $_lang['posts.topic.' . $icon] . "' /></a></td><td class='topic-main-cell'><a href='index.php?m=topic&id=" . $item['id'] . "'>" . $item['subject'] . "</a>" . $tpages . "<br />" . $author . " <small class='post-info'>(" . _formatTime($item['time']) . ")</small></td><td>" . $item['answer_count'] . "</td><td>" . $lastpost . ($item['answer_count'] != 0 ? "<br /><small class='post-info'>(" . _formatTime($item['bumptime']) . ")</small>" : '') . "</td></tr>\n"; $hl = !$hl; } $output .= "</tbody></table><br />\n\n"; if (_pagingmode == 2 or _pagingmode == 3) { $output .= $paging[0] . "<br />"; } // posledni odpovedi $output .= "\n<div class='hr'><hr /></div><br />\n<h3>" . $_lang['posts.forum.lastact'] . "</h3>\n"; $query = DB::query("SELECT topic.id AS topic_id,topic.subject AS topic_subject,answer.author,answer.guest,answer.time FROM `" . _mysql_prefix . "-posts` AS answer JOIN `" . _mysql_prefix . "-posts` AS topic ON(topic.type=5 AND topic.id=answer.xhome) WHERE answer.type=5 AND answer.home=" . $home . " AND answer.xhome!=-1 ORDER BY answer.id DESC LIMIT " . _extratopicslimit); if (DB::size($query) != 0) { $output .= "<ul>\n"; while ($item = DB::row($query)) { if ($item['guest'] == "") { $author = _linkUser($item['author']); } else { $author = "<span class='post-author-guest'>" . $item['guest'] . "</span>"; } $output .= "<li><a href='index.php?m=topic&id=" . $item['topic_id'] . "'>" . $item['topic_subject'] . "</a> <small>(" . $_lang['global.postauthor'] . " " . $author . " " . _formatTime($item['time']) . ")</small></li>\n"; } $output .= "</ul>\n\n"; } else { $output .= "<p>" . $_lang['global.nokit'] . "</p>"; } } } else { $output .= "<p>" . $nopostsmessage . "</p>"; } $output .= "</div>"; return $output; }
function _HCM_articles($typ = 1, $pocet = null, $perex = true, $info = true, $kategorie = null) { // priprava $result = ""; $typ = intval($typ); if ($typ < 1 or $typ > 9) { $typ = 1; } $pocet = intval($pocet); if ($pocet < 1) { $pocet = 1; } $perex = intval($perex); $info = _boolean($info); // limitovani na kategorie $rcats = _sqlArticleWhereCategories($kategorie); // priprava casti sql dotazu switch ($typ) { case 1: $rorder = "art.time DESC"; $rcond = ""; break; case 2: $rorder = "art.readed DESC"; $rcond = "art.readed!=0"; break; case 3: $rorder = "art.ratesum/art.ratenum DESC"; $rcond = "art.ratenum!=0"; break; case 4: $rorder = "art.ratenum DESC"; $rcond = "art.ratenum!=0"; break; case 5: $rorder = "RAND()"; $rcond = ""; break; case 6: $rorder = "(SELECT time FROM `" . _mysql_prefix . "-iplog` WHERE type=2 AND var=art.id AND art.visible=1 AND art.time<=" . time() . " AND art.confirmed=1 ORDER BY id DESC LIMIT 1) DESC"; $rcond = "art.readed!=0"; break; case 7: $rorder = "(SELECT time FROM `" . _mysql_prefix . "-iplog` WHERE type=3 AND var=art.id AND art.visible=1 AND art.time<=" . time() . " AND art.confirmed=1 ORDER BY id DESC LIMIT 1) DESC"; $rcond = "art.ratenum!=0"; break; case 8: $rorder = "(SELECT time FROM `" . _mysql_prefix . "-posts` WHERE home=art.id AND type=2 ORDER BY time DESC LIMIT 1) DESC"; $rcond = "(SELECT COUNT(id) FROM `" . _mysql_prefix . "-posts` WHERE home=art.id AND type=2)!=0"; break; case 9: $rorder = "(SELECT COUNT(id) FROM `" . _mysql_prefix . "-posts` WHERE home=art.id AND type=2) DESC"; $rcond = "(SELECT COUNT(id) FROM `" . _mysql_prefix . "-posts` WHERE home=art.id AND type=2)!=0"; break; } // pripojeni casti if ($rcond != "") { $rcond = " AND " . $rcond; } $rcond = " WHERE " . _sqlArticleFilter(true) . $rcond; if ($rcats != "") { $rcond .= " AND " . $rcats; } // vypis $query = DB::query("SELECT art.id,art.title,art.title_seo,art.perex," . ($perex === 2 ? 'art.picture_uid,' : '') . "art.author,art.time,art.readed,art.comments,cat.title_seo AS cat_title_seo" . ($info !== 0 ? ",(SELECT COUNT(id) FROM `" . _mysql_prefix . "-posts` AS post WHERE home=art.id AND post.type=2) AS comment_count" : '') . " FROM `" . _mysql_prefix . "-articles` AS art JOIN `" . _mysql_prefix . "-root` AS cat ON(cat.id=art.home1)" . $rcond . " ORDER BY " . $rorder . " LIMIT " . $pocet); while ($item = DB::row($query)) { $result .= _articlePreview($item, $info, $perex !== 0, $info !== 0 ? $item['comment_count'] : null); } return $result; }