} if ($is_logged) { $fav_arr = explode(',', $member_id['favorites']); if (!in_array($row['id'], $fav_arr) or $config['allow_cache'] == "yes") { $tpl->set('{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"{$PHP_SELF}?do=favorites&doaction=add&id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/plus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'plus'); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>"); } else { $tpl->set('{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"{$PHP_SELF}?do=favorites&doaction=del&id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/minus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'minus'); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>"); } $tpl->set('[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">"); $tpl->set('[/complaint]', "</a>"); } else { $tpl->set('{favorites}', ""); $tpl->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", ""); } // Обработка дополнительных полей $xfieldsdata = xfieldsdataload($row['xfields']); foreach ($xfields as $value) { $preg_safe_name = preg_quote($value[0], "'"); if ($value[6] and !empty($xfieldsdata[$value[0]])) { $temp_array = explode(",", $xfieldsdata[$value[0]]); $value3 = array(); foreach ($temp_array as $value2) { $value2 = trim($value2); $value2 = str_replace("'", "'", $value2); if ($config['allow_alt_url'] == "yes") { $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode($value2) . "/\">" . $value2 . "</a>"; } else { $value3[] = "<a href=\"{$PHP_SELF}?do=xfsearch&xf=" . urlencode($value2) . "\">" . $value2 . "</a>"; } } $xfieldsdata[$value[0]] = implode(", ", $value3);
case "send": NoAjaxQuery(); $for_user_id = intval($_POST['for_user_id']); $theme = ajax_utf8(textFilter(strip_tags($_POST['theme']))); $msg = ajax_utf8(textFilter($_POST['msg'])); $attach_files = ajax_utf8(textFilter($_POST['attach_files'])); $attach_files = str_replace('vote|', 'hack|', $attach_files); if (!$theme) { $theme = '...'; } if ($user_id != $for_user_id and $for_user_id and isset($msg) and !empty($msg) or isset($attach_files) or !empty($attach_files)) { //Проверка на существование получателя $row = $db->super_query("SELECT user_privacy FROM `" . PREFIX . "_users` WHERE user_id = '{$for_user_id}'"); if ($row) { //Приватность $user_privacy = xfieldsdataload($row['user_privacy']); //ЧС $CheckBlackList = CheckBlackList($for_user_id); //Проверка естьли запрашиваемый юзер в друзьях у юзера который смотрит стр if ($user_privacy['val_msg'] == 2) { $check_friend = CheckFriends($for_user_id); } if (!$CheckBlackList and $user_privacy['val_msg'] == 1 or $user_privacy['val_msg'] == 2 and $check_friend) { $xPrivasy = 1; } else { $xPrivasy = 0; } if ($xPrivasy) { //Отправляем сообщение получателю $db->query("INSERT INTO `" . PREFIX . "_messages` SET theme = '{$theme}', text = '{$msg}', for_user_id = '{$for_user_id}', from_user_id = '{$user_id}', date = '{$server_time}', pm_read = 'no', folder = 'inbox', history_user_id = '{$user_id}', attach = '" . $attach_files . "'"); $dbid = $db->insert_id();
$row['short_story'] = $parse->decodeBBCodes($row['short_story'], false); $row['full_story'] = $parse->decodeBBCodes($row['full_story'], false); } $short_story = $parse->process($row['short_story']); $full_story = $parse->process($row['full_story']); $_POST['title'] = $row['title']; if ($config['allow_admin_wysiwyg'] == "yes" or $row['allow_br'] != '1') { $full_story = $db->safesql($parse->BB_Parse($full_story)); $short_story = $db->safesql($parse->BB_Parse($short_story)); } else { $full_story = $db->safesql($parse->BB_Parse($full_story, false)); $short_story = $db->safesql($parse->BB_Parse($short_story, false)); } if ($row['xfields'] != "") { $xfields = xfieldsload(); $postedxfields = xfieldsdataload($row['xfields']); $filecontents = array(); $newpostedxfields = array(); if (!empty($postedxfields)) { foreach ($xfields as $name => $value) { if ($value[3] == "textarea" and $postedxfields[$value[0]] != "") { if ($config['allow_admin_wysiwyg'] == "yes" or $row['allow_br'] != '1') { $postedxfields[$value[0]] = $parsexf->decodeBBCodes($postedxfields[$value[0]], true, "yes"); $newpostedxfields[$value[0]] = $parsexf->BB_Parse($parsexf->process($postedxfields[$value[0]])); } else { $postedxfields[$value[0]] = $parsexf->decodeBBCodes($postedxfields[$value[0]], false); $newpostedxfields[$value[0]] = $parsexf->BB_Parse($parsexf->process($postedxfields[$value[0]]), false); } } elseif ($postedxfields[$value[0]] != "") { $newpostedxfields[$value[0]] = $parsexf->process(stripslashes($postedxfields[$value[0]])); }
function build_comments($template, $area, $allow_cache = false) { global $config, $tpl, $is_logged, $member_id, $user_group, $lang, $dle_login_hash, $_TIME, $allow_comments_ajax, $ajax_adds; $tpl->load_template($template); $tpl->copy_template = "<div id='comment-id-{id}'>" . $tpl->copy_template . "</div>"; $tpl->template = "<div id='comment-id-{id}'>" . $tpl->template . "</div>"; if (strpos($tpl->copy_template, "[xfvalue_") !== false) { $xfound = true; } else { $xfound = false; } if ($xfound) { $xfields = xfieldsload(true); } if ($area != 'ajax' and $config['comm_msort'] == "DESC") { $tpl->copy_template = "\n<div id=\"dle-ajax-comments\"></div>\n" . $tpl->copy_template; } if ($area != 'ajax') { $tpl->copy_template = "<form method=\"post\" action=\"\" name=\"dlemasscomments\" id=\"dlemasscomments\"><div id=\"dle-comments-list\">\n" . $tpl->copy_template; } if ($area != 'ajax') { $tpl->copy_template = "<a name=\"comment\"></a>" . $tpl->copy_template; } $rows = false; if ($allow_cache) { $rows = dle_cache("comm_" . $allow_cache, $this->query . " LIMIT " . $this->cstart . "," . $this->comments_per_pages); } if ($rows) { $rows = unserialize($rows); $full_cache = true; } else { $rows = $this->db->super_query($this->query . " LIMIT " . $this->cstart . "," . $this->comments_per_pages, true); if ($allow_cache) { create_cache("comm_" . $allow_cache, serialize($rows), $this->query . " LIMIT " . $this->cstart . "," . $this->comments_per_pages); } } if (count($rows)) { foreach ($rows as $row) { $this->intern_count++; $row['date'] = strtotime($row['date']); $row['gast_name'] = stripslashes($row['gast_name']); $row['gast_email'] = stripslashes($row['gast_email']); $row['name'] = stripslashes($row['name']); if (!$row['is_register'] or $row['name'] == '') { if ($row['gast_email'] != "") { $tpl->set('{author}', "<a href=\"mailto:" . htmlspecialchars($row['gast_email'], ENT_QUOTES) . "\">" . $row['gast_name'] . "</a>"); } else { $tpl->set('{author}', $row['gast_name']); } $tpl->set('{login}', $row['gast_name']); $tpl->set('[profile]', ""); $tpl->set('[/profile]', ""); } else { if ($config['allow_alt_url'] == "yes") { $go_page = $config['http_home_url'] . "user/" . urlencode($row['name']) . "/"; $tpl->set('[profile]', "<a href=\"" . $config['http_home_url'] . "user/" . urlencode($row['name']) . "/\">"); } else { $go_page = "{$PHP_SELF}?subaction=userinfo&user="******"<a href=\"{$PHP_SELF}?subaction=userinfo&user="******"\">"); } $go_page = "onclick=\"ShowProfile('" . urlencode($row['name']) . "', '" . htmlspecialchars($go_page) . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\""; if ($config['allow_alt_url'] == "yes") { $tpl->set('{author}', "<a {$go_page} href=\"" . $config['http_home_url'] . "user/" . urlencode($row['name']) . "/\">" . $row['name'] . "</a>"); } else { $tpl->set('{author}', "<a {$go_page} href=\"{$PHP_SELF}?subaction=userinfo&user="******"\">" . $row['name'] . "</a>"); } $tpl->set('{login}', $row['name']); $tpl->set('[/profile]', "</a>"); } if ($is_logged and $member_id['user_group'] == '1') { $tpl->set('{ip}', "IP: <a onclick=\"return dropdownmenu(this, event, IPMenu('" . $row['ip'] . "', '" . $lang['ip_info'] . "', '" . $lang['ip_tools'] . "', '" . $lang['ip_ban'] . "'), '190px')\" href=\"https://www.nic.ru/whois/?ip={$row['ip']}\" target=\"_blank\">{$row['ip']}</a>"); } else { $tpl->set('{ip}', ''); } $edit_limit = false; if (!$user_group[$member_id['user_group']]['edit_limit']) { $edit_limit = true; } elseif ($row['date'] + $user_group[$member_id['user_group']]['edit_limit'] * 60 > $_TIME) { $edit_limit = true; } if ($is_logged and $edit_limit and ($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_editc'] or $user_group[$member_id['user_group']]['edit_allc'])) { $tpl->set('[com-edit]', "<a onclick=\"ajax_comm_edit('" . $row['id'] . "', '" . $area . "'); return false;\" href=\"" . $config['http_home_url'] . "index.php?do=comments&action=comm_edit&id=" . $row['id'] . "&area=" . $area . "\">"); $tpl->set('[/com-edit]', "</a>"); $allow_comments_ajax = true; } else { $tpl->set_block("'\\[com-edit\\](.*?)\\[/com-edit\\]'si", ""); } if ($is_logged and $edit_limit and ($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_delc'] or $member_id['user_group'] == '1' or $user_group[$member_id['user_group']]['del_allc'])) { $tpl->set('[com-del]', "<a href=\"javascript:DeleteComments('{$row['id']}', '{$dle_login_hash}')\">"); $tpl->set('[/com-del]', "</a>"); } else { $tpl->set_block("'\\[com-del\\](.*?)\\[/com-del\\]'si", ""); } if ($user_group[$member_id['user_group']]['del_allc'] and !$user_group[$member_id['user_group']]['edit_limit']) { $tpl->set('{mass-action}', "<input name=\"selected_comments[]\" value=\"{$row['id']}\" type=\"checkbox\" />"); } else { $tpl->set('{mass-action}', ""); } if ($area == 'lastcomments') { $tpl->set_block("'\\[fast\\](.*?)\\[/fast\\]'si", ""); } else { if ($user_group[$member_id['user_group']]['allow_addc'] and $config['allow_comments'] == "yes") { if (!$row['is_register'] or $row['name'] == '') { $row['name'] = $row['gast_name']; } else { $row['name'] = $row['name']; } $tpl->set('[fast]', "<a onmouseover=\"dle_copy_quote('" . str_replace(array(" ", "'"), array(" ", "&#039;"), $row['name']) . "');\" href=\"#\" onclick=\"dle_ins('" . str_replace(array(" ", "'"), array(" ", "&#039;"), $row['name']) . "'); return false;\">"); $tpl->set('[/fast]', "</a>"); } else { $tpl->set_block("'\\[fast\\](.*?)\\[/fast\\]'si", ""); } } $tpl->set('{mail}', $row['email']); $tpl->set('{id}', $row['id']); if (date('Ymd', $row['date']) == date('Ymd', $_TIME)) { $tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date'])); } elseif (date('Ymd', $row['date']) == date('Ymd', $_TIME - 86400)) { $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date'])); } else { $tpl->set('{date}', langdate($config['timestamp_comment'], $row['date'])); } $tpl->copy_template = preg_replace("#\\{date=(.+?)\\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template); if ($area == 'lastcomments') { $row['category'] = intval($row['category']); if ($config['allow_alt_url'] == "yes") { 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['post_id'] . "-" . $row['alt_name'] . ".html"; } else { $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html"; } } else { $full_link = $config['http_home_url'] . date('Y/m/d/', strtotime($row['newsdate'])) . $row['alt_name'] . ".html"; } } else { $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['post_id']; } $tpl->set('{news_title}', "<a href=\"" . $full_link . "\">" . stripslashes($row['title']) . "</a>"); } else { $tpl->set('{news_title}', ""); } if ($xfound) { $xfieldsdata = xfieldsdataload($row['xfields']); foreach ($xfields as $value) { $preg_safe_name = preg_quote($value[0], "'"); if ($value[5] != 1 or $member_id['user_group'] == 1 or $is_logged and $row['is_register'] and $member_id['name'] == $row['name']) { if (empty($xfieldsdata[$value[0]])) { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = str_replace("[xfnotgiven_{$preg_safe_name}]", "", $tpl->copy_template); $tpl->copy_template = str_replace("[/xfnotgiven_{$preg_safe_name}]", "", $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = str_replace("[xfgiven_{$preg_safe_name}]", "", $tpl->copy_template); $tpl->copy_template = str_replace("[/xfgiven_{$preg_safe_name}]", "", $tpl->copy_template); } $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", stripslashes($xfieldsdata[$value[0]]), $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", "", $tpl->copy_template); $tpl->copy_template = preg_replace("'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); } } } if ($area == 'ajax' and isset($ajax_adds)) { $tpl->set('{comment-id}', "--"); } elseif ($area == 'lastcomments') { $tpl->set('{comment-id}', $this->total_comments - $this->cstart - $this->intern_count + 1); } else { if ($config['comm_msort'] == "ASC") { $tpl->set('{comment-id}', $this->cstart + $this->intern_count); } else { $tpl->set('{comment-id}', $this->total_comments - $this->cstart - $this->intern_count + 1); } } if ($row['foto']) { $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $row['foto']); } else { $tpl->set('{foto}', "{THEME}/images/noavatar.png"); } if ($row['is_register'] and $row['fullname']) { $tpl->set('[fullname]', ""); $tpl->set('[/fullname]', ""); $tpl->set('{fullname}', stripslashes($row['fullname'])); $tpl->set_block("'\\[not-fullname\\](.*?)\\[/not-fullname\\]'si", ""); } else { $tpl->set_block("'\\[fullname\\](.*?)\\[/fullname\\]'si", ""); $tpl->set('{fullname}', ""); $tpl->set('[not-fullname]', ""); $tpl->set('[/not-fullname]', ""); } if ($row['is_register'] and $row['icq']) { $tpl->set('[icq]', ""); $tpl->set('[/icq]', ""); $tpl->set('{icq}', stripslashes($row['icq'])); $tpl->set_block("'\\[not-icq\\](.*?)\\[/not-icq\\]'si", ""); } else { $tpl->set_block("'\\[icq\\](.*?)\\[/icq\\]'si", ""); $tpl->set('{icq}', ""); $tpl->set('[not-icq]', ""); $tpl->set('[/not-icq]', ""); } if ($row['is_register'] and $row['land']) { $tpl->set('[land]', ""); $tpl->set('[/land]', ""); $tpl->set('{land}', stripslashes($row['land'])); $tpl->set_block("'\\[not-land\\](.*?)\\[/not-land\\]'si", ""); } else { $tpl->set_block("'\\[land\\](.*?)\\[/land\\]'si", ""); $tpl->set('{land}', ""); $tpl->set('[not-land]', ""); $tpl->set('[/not-land]', ""); } if ($row['comm_num']) { $tpl->set('[comm-num]', ""); $tpl->set('[/comm-num]', ""); $tpl->set('{comm-num}', $row['comm_num']); $tpl->set_block("'\\[not-comm-num\\](.*?)\\[/not-comm-num\\]'si", ""); } else { $tpl->set('{comm-num}', 0); $tpl->set('[not-comm-num]', ""); $tpl->set('[/not-comm-num]', ""); $tpl->set_block("'\\[comm-num\\](.*?)\\[/comm-num\\]'si", ""); } if ($row['news_num']) { $tpl->set('[news-num]', ""); $tpl->set('[/news-num]', ""); $tpl->set('{news-num}', $row['news_num']); $tpl->set_block("'\\[not-news-num\\](.*?)\\[/not-news-num\\]'si", ""); } else { $tpl->set('{news-num}', 0); $tpl->set('[not-news-num]', ""); $tpl->set('[/not-news-num]', ""); $tpl->set_block("'\\[news-num\\](.*?)\\[/news-num\\]'si", ""); } if ($row['is_register'] and $row['reg_date']) { $tpl->set('{registration}', langdate("j.m.Y", $row['reg_date'])); } else { $tpl->set('{registration}', '--'); } if ($row['is_register'] and $row['lastdate']) { $tpl->set('{lastdate}', langdate("j.m.Y", $row['lastdate'])); if ($row['lastdate'] + 1200 > $_TIME or $row['user_id'] and $row['user_id'] == $member_id['user_id']) { $tpl->set('[online]', ""); $tpl->set('[/online]', ""); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); } else { $tpl->set('[offline]', ""); $tpl->set('[/offline]', ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } } else { $tpl->set('{lastdate}', '--'); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } if ($row['is_register'] and $row['signature'] and $user_group[$row['user_group']]['allow_signature']) { $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", "\\1"); $tpl->set('{signature}', stripslashes($row['signature'])); } else { $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", ""); } if ($is_logged) { $tpl->set('[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">"); $tpl->set('[/complaint]', "</a>"); } else { $tpl->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", ""); } if (!$row['user_group']) { $row['user_group'] = 5; } if ($user_group[$row['user_group']]['icon']) { $tpl->set('{group-icon}', "<img src=\"" . $user_group[$row['user_group']]['icon'] . "\" alt=\"\" />"); } else { $tpl->set('{group-icon}', ""); } $tpl->set('{group-name}', $user_group[$row['user_group']]['group_prefix'] . $user_group[$row['user_group']]['group_name'] . $user_group[$row['user_group']]['group_suffix']); if (count($this->extras_rules)) { foreach ($this->extras_rules as $rules) { if ($rules[0] == 'set') { $tpl->set($rules[1], $rules[2]); } else { $tpl->set_block($rules[1], $rules[2]); } } } if ($user_group[$member_id['user_group']]['allow_hide']) { $row['text'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $row['text'])); } else { $row['text'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $row['text']); } $tpl->set('{comment}', "<div id='comm-id-" . $row['id'] . "'>" . stripslashes($row['text']) . "</div>"); $tpl->compile('comments'); } } else { $tpl->result['comments'] = ""; if ($area != 'ajax' and $config['comm_msort'] == "DESC") { $tpl->result['comments'] = "\n<div id=\"dle-ajax-comments\"></div>\n"; } if ($area != 'ajax') { $tpl->result['comments'] = "<form method=\"post\" action=\"\" name=\"dlemasscomments\" id=\"dlemasscomments\"><div id=\"dle-comments-list\">\n" . $tpl->result['comments']; } if ($area != 'ajax') { $tpl->result['comments'] = "<a name=\"comment\"></a>" . $tpl->result['comments']; } } $tpl->clear(); if ($area != 'ajax' and $config['comm_msort'] == "ASC") { $tpl->result['comments'] .= "\n<div id=\"dle-ajax-comments\"></div>\n"; } if ($area != 'ajax' and $user_group[$member_id['user_group']]['del_allc'] and !$user_group[$member_id['user_group']]['edit_limit']) { $tpl->result['comments'] .= "\n<div class=\"mass_comments_action\">{$lang['mass_comments']} <select name=\"mass_action\"><option value=\"\">{$lang['edit_selact']}</option><option value=\"mass_combine\">{$lang['edit_selcomb']}</option><option value=\"mass_delete\">{$lang['edit_seldel']}</option></select> <input type=\"submit\" class=\"bbcodes\" value=\"{$lang['b_start']}\" /></div>\n<input type=\"hidden\" name=\"do\" value=\"comments\" /><input type=\"hidden\" name=\"dle_allow_hash\" value=\"{$dle_login_hash}\" /><input type=\"hidden\" name=\"area\" value=\"{$area}\" />"; } if ($area != 'ajax') { $tpl->result['comments'] .= "</div></form>\n"; } if (strpos($tpl->result['content'], "<!--dlecomments-->") !== false) { $tpl->result['content'] = str_replace("<!--dlecomments-->", $tpl->result['comments'], $tpl->result['content']); } else { $tpl->result['content'] .= $tpl->result['comments']; } }
$text = $parse->BB_Parse($parse->process($_POST['text']), false); } else { $parse->wysiwyg = true; $parse->ParseFilter(array('div', 'span', 'p', 'br', 'strong', 'em', 'ul', 'li', 'ol'), array(), 0, 1); $text = $parse->BB_Parse($parse->process($_POST['text'])); } $tpl->load_template('pm.tpl'); preg_replace("'\\[readpm\\](.*?)\\[/readpm\\]'ies", "del_tpl('\\1')", $tpl->copy_template); if (strpos($tpl->copy_template, "[xfvalue_") !== false) { $xfound = true; } else { $xfound = false; } if ($xfound) { $xfields = xfieldsload(true); $xfieldsdata = xfieldsdataload($member_id['xfields']); foreach ($xfields as $value) { $preg_safe_name = preg_quote($value[0], "'"); if ($value[5] != 1 or $member_id['user_group'] == 1 or $is_logged and $member_id['name'] == $row['user_from']) { if (empty($xfieldsdata[$value[0]])) { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "\\1", $tpl->copy_template); } $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", stripslashes($xfieldsdata[$value[0]]), $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", "", $tpl->copy_template); } } }
if ($val_wall3 <= 0 or $val_wall3 > 3) { $val_wall3 = 1; } if ($val_info <= 0 or $val_info > 3) { $val_info = 1; } $user_privacy = "val_msg|{$val_msg}||val_wall1|{$val_wall1}||val_wall2|{$val_wall2}||val_wall3|{$val_wall3}||val_info|{$val_info}||"; $db->query("UPDATE `" . PREFIX . "_users` SET user_privacy = '{$user_privacy}' WHERE user_id = '{$user_id}'"); mozg_clear_cache_file('user_' . $user_id . '/profile_' . $user_id); die; break; //################### Приватность настройки ###################// //################### Приватность настройки ###################// case "privacy": $sql_ = $db->super_query("SELECT user_privacy FROM `" . PREFIX . "_users` WHERE user_id = '{$user_id}'"); $row = xfieldsdataload($sql_['user_privacy']); $tpl->load_template('settings/privacy.tpl'); $tpl->set('{val_msg}', $row['val_msg']); $tpl->set('{val_msg_text}', strtr($row['val_msg'], array('1' => 'Все пользователи', '2' => 'Только друзья', '3' => 'Никто'))); $tpl->set('{val_wall1}', $row['val_wall1']); $tpl->set('{val_wall1_text}', strtr($row['val_wall1'], array('1' => 'Все пользователи', '2' => 'Только друзья', '3' => 'Только я'))); $tpl->set('{val_wall2}', $row['val_wall2']); $tpl->set('{val_wall2_text}', strtr($row['val_wall2'], array('1' => 'Все пользователи', '2' => 'Только друзья', '3' => 'Только я'))); $tpl->set('{val_wall3}', $row['val_wall3']); $tpl->set('{val_wall3_text}', strtr($row['val_wall3'], array('1' => 'Все пользователи', '2' => 'Только друзья', '3' => 'Только я'))); $tpl->set('{val_info}', $row['val_info']); $tpl->set('{val_info_text}', strtr($row['val_info'], array('1' => 'Все пользователи', '2' => 'Только друзья', '3' => 'Только я'))); $tpl->compile('info'); break; //################### Добавление в черный список ###################// //################### Добавление в черный список ###################//
$xfielddatavalue = str_replace("\r\n", "__NEWL__", $xfielddatavalue); $filecontents[] = "{$xfielddataname}|{$xfielddatavalue}"; } if (count($filecontents)) { $filecontents = $db->safesql(implode("||", $filecontents)); } else { $filecontents = ''; } } else { $filecontents = ''; } break; case "delete": break; case "templatereplace": $xfieldsdata = xfieldsdataload($xfieldsid); $xfieldsoutput = $xfieldsinput; foreach ($xfields as $value) { $preg_safe_name = preg_quote($value[0], "'"); if ($value[5] != 0) { if (empty($xfieldsdata[$value[0]])) { $xfieldsoutput = preg_replace("'\\[xfgiven_{$preg_safe_name}\\].*?\\[/xfgiven_{$preg_safe_name}\\]'is", "", $xfieldsoutput); } else { $xfieldsoutput = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "\\1", $xfieldsoutput); } } $xfieldsoutput = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", stripslashes($xfieldsdata[$value[0]]), $xfieldsoutput); } break; case "templatereplacepreview": if (isset($_POST["xfield"])) {
$section = $_POST['section']; //ЧС $CheckBlackList = CheckBlackList($user_id); if (!$CheckBlackList) { //Получаем ID альбома $check_album = $db->super_query("SELECT album_id FROM `" . PREFIX . "_photos` WHERE id = '{$photo_id}'"); //Если фотография вызвана не со стены if (!$fuser and $check_album) { //Проверяем на наличии файла с позициям только для этого фоток $check_pos = mozg_cache('user_' . $user_id . '/position_photos_album_' . $check_album['album_id']); //Если нету, то вызываем функцию генерации if (!$check_pos) { GenerateAlbumPhotosPosition($user_id, $check_album['album_id']); $check_pos = mozg_cache('user_' . $user_id . '/position_photos_album_' . $check_album['album_id']); } $position = xfieldsdataload($check_pos); } $row = $db->super_query("SELECT tb1.id, photo_name, comm_num, descr, date, position, tb2.user_id, user_search_pref, user_country_city_name FROM `" . PREFIX . "_photos` tb1, `" . PREFIX . "_users` tb2 WHERE id = '{$photo_id}' AND tb1.user_id = tb2.user_id"); if ($row) { //Вывод названия альбома, приватноть из БД $info_album = $db->super_query("SELECT name, privacy FROM `" . PREFIX . "_albums` WHERE aid = '{$check_album['album_id']}'"); $album_privacy = explode('|', $info_album['privacy']); //Проверка естьли запрашиваемый юзер в друзьях у юзера который смотрит стр if ($user_info['user_id'] != $row['user_id']) { $check_friend = CheckFriends($row['user_id']); } //Приватность if ($album_privacy[0] == 1 or $album_privacy[0] == 2 and $check_friend or $user_info['user_id'] == $row['user_id']) { //Если фотография вызвана не со стены if (!$fuser) { $exp_photo_num = count(explode('||', $check_pos));
function compile_comment($row, $area, $indent) { global $config, $tpl, $is_logged, $member_id, $user_group, $lang, $dle_login_hash, $_TIME, $allow_comments_ajax, $ajax_adds, $news_date, $news_author, $replace_links; $PHP_SELF = $config['http_home_url'] . "index.php"; $this->intern_count++; $tpl->result['comments'] = ""; $row['date'] = strtotime($row['date']); $row['gast_name'] = stripslashes($row['gast_name']); $row['gast_email'] = stripslashes($row['gast_email']); $row['name'] = stripslashes($row['name']); if (!$row['is_register'] or $row['name'] == '') { if ($row['gast_email'] != "") { $tpl->set('{author}', "<a href=\"mailto:" . htmlspecialchars($row['gast_email'], ENT_QUOTES, $config['charset']) . "\">" . $row['gast_name'] . "</a>"); } else { $tpl->set('{author}', $row['gast_name']); } $tpl->set('{login}', $row['gast_name']); $tpl->set('[profile]', ""); $tpl->set('[/profile]', ""); } else { if ($config['allow_alt_url']) { $go_page = $config['http_home_url'] . "user/" . urlencode($row['name']) . "/"; $tpl->set('[profile]', "<a href=\"" . $config['http_home_url'] . "user/" . urlencode($row['name']) . "/\">"); } else { $go_page = "{$PHP_SELF}?subaction=userinfo&user="******"<a href=\"{$PHP_SELF}?subaction=userinfo&user="******"\">"); } $go_page = "onclick=\"ShowProfile('" . urlencode($row['name']) . "', '" . htmlspecialchars($go_page, ENT_QUOTES, $config['charset']) . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\""; if ($config['allow_alt_url']) { $tpl->set('{author}', "<a {$go_page} href=\"" . $config['http_home_url'] . "user/" . urlencode($row['name']) . "/\">" . $row['name'] . "</a>"); } else { $tpl->set('{author}', "<a {$go_page} href=\"{$PHP_SELF}?subaction=userinfo&user="******"\">" . $row['name'] . "</a>"); } $tpl->set('{login}', $row['name']); $tpl->set('[/profile]', "</a>"); } if ($is_logged and $member_id['user_group'] == '1') { $tpl->set('{ip}', "IP: <a onclick=\"return dropdownmenu(this, event, IPMenu('" . $row['ip'] . "', '" . $lang['ip_info'] . "', '" . $lang['ip_tools'] . "', '" . $lang['ip_ban'] . "'), '190px')\" href=\"https://www.nic.ru/whois/?ip={$row['ip']}\" target=\"_blank\">{$row['ip']}</a>"); } else { $tpl->set('{ip}', ''); } $edit_limit = false; if (!$user_group[$member_id['user_group']]['edit_limit']) { $edit_limit = true; } elseif ($row['date'] + $user_group[$member_id['user_group']]['edit_limit'] * 60 > $_TIME) { $edit_limit = true; } if ($is_logged and $edit_limit and ($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_editc'] or $user_group[$member_id['user_group']]['edit_allc'])) { $tpl->set('[com-edit]', "<a onclick=\"ajax_comm_edit('" . $row['id'] . "', '" . $area . "'); return false;\" href=\"" . $config['http_home_url'] . "index.php?do=comments&action=comm_edit&id=" . $row['id'] . "&area=" . $area . "\">"); $tpl->set('[/com-edit]', "</a>"); $allow_comments_ajax = true; } else { $tpl->set_block("'\\[com-edit\\](.*?)\\[/com-edit\\]'si", ""); } if ($is_logged and $edit_limit and ($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_delc'] or $member_id['user_group'] == '1' or $user_group[$member_id['user_group']]['del_allc'])) { $tpl->set('[com-del]', "<a href=\"javascript:DeleteComments('{$row['id']}', '{$dle_login_hash}')\">"); $tpl->set('[/com-del]', "</a>"); } else { $tpl->set_block("'\\[com-del\\](.*?)\\[/com-del\\]'si", ""); } if ($is_logged and $user_group[$member_id['user_group']]['allow_admin'] and $user_group[$member_id['user_group']]['del_allc']) { $tpl->set('[spam]', "<a href=\"javascript:MarkSpam('{$row['id']}', '{$dle_login_hash}');\">"); $tpl->set('[/spam]', "</a>"); } else { $tpl->set_block("'\\[spam\\](.*?)\\[/spam\\]'si", ""); } if ($user_group[$member_id['user_group']]['del_allc'] and !$user_group[$member_id['user_group']]['edit_limit']) { $tpl->set('{mass-action}', "<input name=\"selected_comments[]\" value=\"{$row['id']}\" type=\"checkbox\" />"); } else { $tpl->set('{mass-action}', ""); } if ($area == 'lastcomments') { $tpl->set_block("'\\[fast\\](.*?)\\[/fast\\]'si", ""); $tpl->set_block("'\\[reply\\](.*?)\\[/reply\\]'si", ""); } else { if ($user_group[$member_id['user_group']]['allow_addc'] and $config['allow_comments']) { if (!$row['is_register'] or $row['name'] == '') { $row['name'] = $row['gast_name']; } else { $row['name'] = $row['name']; } $tpl->set('[fast]', "<a onmouseover=\"dle_copy_quote('" . str_replace(array(" ", "'"), array(" ", "&#039;"), $row['name']) . "');\" href=\"#\" onclick=\"dle_ins('{$row['id']}'); return false;\">"); $tpl->set('[/fast]', "</a>"); $tpl->set('[/reply]', "</a>"); if ($config['tree_comments']) { if ($config['tree_comments_level'] and ($indent >= $config['tree_comments_level'] or $this->indent >= $config['tree_comments_level'])) { $tpl->set('[reply]', "<a onclick=\"dle_fastreply('" . str_replace(array(" ", "'"), array(" ", "&#039;"), $row['name']) . "'); return false;\" href=\"#\">"); } else { if ($this->indent) { $indent = $this->indent; } $tpl->set('[reply]', "<a onclick=\"dle_reply('{$row['id']}', '{$indent}', '{$config['simple_reply']}'); return false;\" href=\"#\">"); } } else { $tpl->set('[reply]', "<a onclick=\"dle_fastreply('" . str_replace(array(" ", "'"), array(" ", "&#039;"), $row['name']) . "'); return false;\" href=\"#\">"); } } else { $tpl->set_block("'\\[fast\\](.*?)\\[/fast\\]'si", ""); $tpl->set_block("'\\[reply\\](.*?)\\[/reply\\]'si", ""); } } $tpl->set('{mail}', $row['gast_email']); $tpl->set('{id}', $row['id']); if (date('Ymd', $row['date']) == date('Ymd', $_TIME)) { $tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date'])); } elseif (date('Ymd', $row['date']) == date('Ymd', $_TIME - 86400)) { $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date'])); } else { $tpl->set('{date}', langdate($config['timestamp_comment'], $row['date'])); } $news_date = $row['date']; $tpl->copy_template = preg_replace_callback("#\\{date=(.+?)\\}#i", "formdate", $tpl->copy_template); if ($area == 'lastcomments') { $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['post_id'] . "-" . $row['alt_name'] . ".html"; } else { $full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html"; } } else { $full_link = $config['http_home_url'] . date('Y/m/d/', strtotime($row['newsdate'])) . $row['alt_name'] . ".html"; } } else { $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['post_id']; } $tpl->set('{news_title}', "<a href=\"" . $full_link . "\">" . stripslashes($row['title']) . "</a>"); } else { $tpl->set('{news_title}', ""); } if ($this->xfound) { $xfieldsdata = xfieldsdataload($row['xfields']); foreach ($this->xfields as $value) { $preg_safe_name = preg_quote($value[0], "'"); if ($value[5] != 1 or $member_id['user_group'] == 1 or $is_logged and $row['is_register'] and $member_id['name'] == $row['name']) { if (empty($xfieldsdata[$value[0]])) { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = str_replace("[xfnotgiven_{$value[0]}]", "", $tpl->copy_template); $tpl->copy_template = str_replace("[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = str_replace("[xfgiven_{$value[0]}]", "", $tpl->copy_template); $tpl->copy_template = str_replace("[/xfgiven_{$value[0]}]", "", $tpl->copy_template); } $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", stripslashes($xfieldsdata[$value[0]]), $tpl->copy_template); } else { $tpl->copy_template = preg_replace("'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); $tpl->copy_template = preg_replace("'\\[xfvalue_{$preg_safe_name}\\]'i", "", $tpl->copy_template); $tpl->copy_template = preg_replace("'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template); } } } if ($area == 'ajax' and isset($ajax_adds)) { $tpl->set('{comment-id}', "--"); } elseif ($area == 'lastcomments') { $tpl->set('{comment-id}', $this->total_comments - $this->cstart - $this->intern_count + 1); } else { if ($config['comm_msort'] == "ASC") { $tpl->set('{comment-id}', $this->cstart + $this->intern_count); } else { $tpl->set('{comment-id}', $this->total_comments - $this->cstart - $this->intern_count + 1); } } if (count(explode("@", $row['foto'])) == 2) { $tpl->set('{foto}', '//www.gravatar.com/avatar/' . md5(trim($row['foto'])) . '?s=' . intval($user_group[$row['user_group']]['max_foto'])); } else { if ($row['foto']) { if (strpos($row['foto'], "//") === 0) { $avatar = "http:" . $row['foto']; } else { $avatar = $row['foto']; } $avatar = @parse_url($avatar); if ($avatar['host']) { $tpl->set('{foto}', $row['foto']); } else { $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $row['foto']); } } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } } if ($row['is_register'] and $row['fullname']) { $tpl->set('[fullname]', ""); $tpl->set('[/fullname]', ""); $tpl->set('{fullname}', stripslashes($row['fullname'])); $tpl->set_block("'\\[not-fullname\\](.*?)\\[/not-fullname\\]'si", ""); } else { $tpl->set_block("'\\[fullname\\](.*?)\\[/fullname\\]'si", ""); $tpl->set('{fullname}', ""); $tpl->set('[not-fullname]', ""); $tpl->set('[/not-fullname]', ""); } if ($config['tree_comments']) { $tpl->set('[treecomments]', ""); $tpl->set('[/treecomments]', ""); $tpl->set_block("'\\[not-treecomments\\](.*?)\\[/not-treecomments\\]'si", ""); } else { $tpl->set('[not-treecomments]', ""); $tpl->set('[/not-treecomments]', ""); $tpl->set_block("'\\[treecomments\\](.*?)\\[/treecomments\\]'si", ""); } if ($indent or $this->indent) { $tpl->set_block("'\\[rootcomments\\](.*?)\\[/rootcomments\\]'si", ""); $tpl->set('[childrencomments]', ""); $tpl->set('[/childrencomments]', ""); } else { $tpl->set('[rootcomments]', ""); $tpl->set('[/rootcomments]', ""); $tpl->set_block("'\\[childrencomments\\](.*?)\\[/childrencomments\\]'si", ""); } if (isset($row['children'])) { $tpl->set('{replycount}', count($row['children'])); } else { $tpl->set('{replycount}', 0); } if ($row['user_id'] and $row['user_id'] == $member_id['user_id']) { $tpl->set('[comments-author]', ""); $tpl->set('[/comments-author]', ""); $tpl->set_block("'\\[not-comments-author\\](.*?)\\[/not-comments-author\\]'si", ""); } else { $tpl->set_block("'\\[comments-author\\](.*?)\\[/comments-author\\]'si", ""); $tpl->set('[not-comments-author]', ""); $tpl->set('[/not-comments-author]', ""); } if ($news_author and $row['user_id'] and $row['user_id'] == $news_author) { $tpl->set('[news-author]', ""); $tpl->set('[/news-author]', ""); $tpl->set_block("'\\[not-news-author\\](.*?)\\[/not-news-author\\]'si", ""); } else { $tpl->set_block("'\\[news-author\\](.*?)\\[/news-author\\]'si", ""); $tpl->set('[not-news-author]', ""); $tpl->set('[/not-news-author]', ""); } if ($row['is_register'] and $row['land']) { $tpl->set('[land]', ""); $tpl->set('[/land]', ""); $tpl->set('{land}', stripslashes($row['land'])); $tpl->set_block("'\\[not-land\\](.*?)\\[/not-land\\]'si", ""); } else { $tpl->set_block("'\\[land\\](.*?)\\[/land\\]'si", ""); $tpl->set('{land}', ""); $tpl->set('[not-land]', ""); $tpl->set('[/not-land]', ""); } if ($row['comm_num']) { $tpl->set('[comm-num]', ""); $tpl->set('[/comm-num]', ""); $tpl->set('{comm-num}', $row['comm_num']); $tpl->set_block("'\\[not-comm-num\\](.*?)\\[/not-comm-num\\]'si", ""); } else { $tpl->set('{comm-num}', 0); $tpl->set('[not-comm-num]', ""); $tpl->set('[/not-comm-num]', ""); $tpl->set_block("'\\[comm-num\\](.*?)\\[/comm-num\\]'si", ""); } if ($row['news_num']) { $tpl->set('[news-num]', ""); $tpl->set('[/news-num]', ""); $tpl->set('{news-num}', $row['news_num']); $tpl->set_block("'\\[not-news-num\\](.*?)\\[/not-news-num\\]'si", ""); } else { $tpl->set('{news-num}', 0); $tpl->set('[not-news-num]', ""); $tpl->set('[/not-news-num]', ""); $tpl->set_block("'\\[news-num\\](.*?)\\[/news-num\\]'si", ""); } if ($row['is_register'] and $row['reg_date']) { $tpl->set('{registration}', langdate("j.m.Y", $row['reg_date'])); } else { $tpl->set('{registration}', '--'); } if ($row['is_register'] and $row['lastdate']) { $tpl->set('{lastdate}', langdate("j.m.Y", $row['lastdate'])); if ($row['lastdate'] + 1200 > $_TIME or $row['user_id'] and $row['user_id'] == $member_id['user_id']) { $tpl->set('[online]', ""); $tpl->set('[/online]', ""); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); } else { $tpl->set('[offline]', ""); $tpl->set('[/offline]', ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } } else { $tpl->set('{lastdate}', '--'); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } if ($row['is_register'] and $row['signature'] and $user_group[$row['user_group']]['allow_signature']) { $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", "\\1"); $tpl->set('{signature}', stripslashes($row['signature'])); } else { $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", ""); } if ($is_logged) { $tpl->set('[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'comments')\">"); $tpl->set('[/complaint]', "</a>"); } else { $tpl->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", ""); } if ($config['comments_rating_type'] == "1") { $tpl->set('[rating-type-2]', ""); $tpl->set('[/rating-type-2]', ""); $tpl->set_block("'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", ""); $tpl->set_block("'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", ""); } elseif ($config['comments_rating_type'] == "2") { $tpl->set('[rating-type-3]', ""); $tpl->set('[/rating-type-3]', ""); $tpl->set_block("'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", ""); $tpl->set_block("'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", ""); } else { $tpl->set('[rating-type-1]', ""); $tpl->set('[/rating-type-1]', ""); $tpl->set_block("'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", ""); $tpl->set_block("'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", ""); } if ($config['allow_comments_rating']) { $tpl->set('{rating}', ShowCommentsRating($row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_comments_rating'])); $tpl->set('{vote-num}', "<span id=\"comments-vote-num-id-" . $row['id'] . "\">" . $row['vote_num'] . "</span>"); $tpl->set('[rating]', ""); $tpl->set('[/rating]', ""); if ($row['rating'] > 0) { $tpl->set('[positive-comment]', ""); $tpl->set('[/positive-comment]', ""); $tpl->set_block("'\\[negative-comment\\](.*?)\\[/negative-comment\\]'si", ""); $tpl->set_block("'\\[neutral-comment\\](.*?)\\[/neutral-comment\\]'si", ""); } elseif ($row['rating'] < 0) { $tpl->set('[negative-comment]', ""); $tpl->set('[/negative-comment]', ""); $tpl->set_block("'\\[positive-comment\\](.*?)\\[/positive-comment\\]'si", ""); $tpl->set_block("'\\[neutral-comment\\](.*?)\\[/neutral-comment\\]'si", ""); } else { $tpl->set('[neutral-comment]', ""); $tpl->set('[/neutral-comment]', ""); $tpl->set_block("'\\[positive-comment\\](.*?)\\[/positive-comment\\]'si", ""); $tpl->set_block("'\\[negative-comment\\](.*?)\\[/negative-comment\\]'si", ""); } if ($user_group[$member_id['user_group']]['allow_comments_rating']) { if ($config['comments_rating_type']) { $tpl->set('[rating-plus]', "<a href=\"#\" onclick=\"doCommentsRate('plus', '{$row['id']}'); return false;\" >"); $tpl->set('[/rating-plus]', '</a>'); if ($config['comments_rating_type'] == "2") { $tpl->set('[rating-minus]', "<a href=\"#\" onclick=\"doCommentsRate('minus', '{$row['id']}'); return false;\" >"); $tpl->set('[/rating-minus]', '</a>'); } else { $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); } } else { $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); } } else { $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); } } else { $tpl->set('{rating}', ""); $tpl->set('{vote-num}', ""); $tpl->set_block("'\\[rating\\](.*?)\\[/rating\\]'si", ""); $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); } if (!$row['user_group']) { $row['user_group'] = 5; } $this->comments_group = $row['user_group']; if (strpos($tpl->copy_template, "[commentsgroup=") !== false) { $tpl->copy_template = preg_replace_callback("#\\[(commentsgroup)=(.+?)\\](.*?)\\[/commentsgroup\\]#is", array(&$this, 'check_group'), $tpl->copy_template); } if (strpos($tpl->copy_template, "[not-commentsgroup=") !== false) { $tpl->copy_template = preg_replace_callback("#\\[(not-commentsgroup)=(.+?)\\](.*?)\\[/not-commentsgroup\\]#is", array(&$this, 'check_group'), $tpl->copy_template); } if (strpos($tpl->copy_template, "[commentscount=") !== false) { $tpl->copy_template = preg_replace_callback("#\\[(commentscount)=(.+?)\\](.*?)\\[/commentscount\\]#is", array(&$this, 'check_commentscount'), $tpl->copy_template); } if (strpos($tpl->copy_template, "[not-commentscount=") !== false) { $tpl->copy_template = preg_replace_callback("#\\[(not-commentscount)=(.+?)\\](.*?)\\[/not-commentscount\\]#is", array(&$this, 'check_commentscount'), $tpl->copy_template); } if ($user_group[$row['user_group']]['icon']) { $tpl->set('{group-icon}', "<img src=\"" . $user_group[$row['user_group']]['icon'] . "\" alt=\"\" />"); } else { $tpl->set('{group-icon}', ""); } $tpl->set('{group-name}', $user_group[$row['user_group']]['group_prefix'] . $user_group[$row['user_group']]['group_name'] . $user_group[$row['user_group']]['group_suffix']); if (count($this->extras_rules)) { foreach ($this->extras_rules as $rules) { if ($rules[0] == 'set') { $tpl->set($rules[1], $rules[2]); } else { $tpl->set_block($rules[1], $rules[2]); } } } if ($config['allow_links'] and function_exists('replace_links') and isset($replace_links['comments'])) { $row['text'] = replace_links($row['text'], $replace_links['comments']); } if ($user_group[$member_id['user_group']]['allow_hide']) { $row['text'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $row['text'])); } else { $row['text'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $row['text']); } $tpl->set('{comment}', "<div id='comm-id-" . $row['id'] . "'>" . stripslashes($row['text']) . "</div>"); $tpl->compile('comments'); return $tpl->result['comments']; }
public function runBlockPro() { // Защита от фашистов )))) (НУЖНА ЛИ? ) $this->config['post_id'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['post_id']))); $this->config['not_post_id'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['not_post_id']))); $this->config['author'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['author']))); $this->config['not_author'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['not_author']))); $this->config['xfilter'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['xfilter']))); $this->config['not_xfilter'] = @$this->db->safesql(strip_tags(str_replace('/', '', $this->config['not_xfilter']))); // Определяем сегодняшнюю дату $tooday = date( "Y-m-d H:i:s", (time() + $this->dle_config['date_adjust'] * 60) ); // Проверка версии DLE if ($this->dle_config['version_id'] >= 9.6) $newVersion = true; // Пробуем подгрузить содержимое модуля из кэша $output = false; // Если установлено время жизи кеша - убираем префикс news_ чтобы кеш не чистился автоматом // и задаём настройки времени жизни кеша в секундах (надо доработать, где то косяк) if ($this->config['cache_live']) { $this->config['prefix'] = ''; $filedate = ENGINE_DIR.'/cache/'.$this->config['prefix'].'bp_'.md5(implode('_', $this->config)).'.tmp'; if(@file_exists($filedate)) $cache_time=time()-@filemtime ($filedate); else $cache_time = $this->config['cache_live']*60; if ($cache_time>=$this->config['cache_live']*60) $clear_time_cache = 1; } // Если nocache не установлен - добавляем префикс (по умолчанию news_) к файлу кеша. if( !$this->config['nocache']) { $output = dle_cache($this->config['prefix'].'bp_'.md5(implode('_', $this->config))); } if ($clear_time_cache) { $output = false; } // Если значение кэша для данной конфигурации получено, выводим содержимое кэша if($output !== false) { $this->showOutput($output); return; } // Если в кэше ничего не найдено, генерируем модуль заново $wheres = array(); // Условие для отображения только постов, прошедших модерацию $wheres[] = 'approve'; // Разбираемся с временными рамками отбора новостей, если кол-во дней указано - ограничиваем выборку, если нет - выводим без ограничения даты // if ($this->config['day']) // { // $interval = $this->config['day']; // $dateStart = 'AND date >= "'.$tooday.'" - INTERVAL "'.$interval.'" DAY'; // } // if (!$this->config['day']) // { // $dateStart = ''; // } // Фильтрация КАТЕГОРИЙ по их ID if ($this->config['cat_id'] == 'this') $this->config['cat_id'] = $this->category_id; if ($this->config['not_cat_id'] == 'this') $this->config['not_cat_id'] = $this->category_id; if ($this->config['cat_id'] || $this->config['not_cat_id']) { $ignore = ($this->config['not_cat_id']) ? 'NOT ' : ''; $catArr = ($this->config['not_cat_id']) ? $this->config['not_cat_id'] : $this->config['cat_id']; $wheres[] = $ignore.'category regexp "[[:<:]]('.str_replace(',', '|', $catArr).')[[:>:]]"'; } // Фильтрация НОВОСТЕЙ по их ID if ($this->config['post_id'] == 'this') $this->config['post_id'] = $_REQUEST["newsid"]; if ($this->config['not_post_id'] == 'this') $this->config['not_post_id'] = $_REQUEST["newsid"]; if ($this->config['post_id'] || $this->config['not_post_id']) { $ignorePosts = ($this->config['not_post_id']) ? 'NOT ' : ''; $postsArr = ($this->config['not_post_id']) ? $this->config['not_post_id'] : $this->config['post_id']; $wheres[] = $ignorePosts.'id regexp "[[:<:]]('.str_replace(',', '|', $postsArr).')[[:>:]]"'; } // Фильтрация новостей по АВТОРАМ if ($this->config['author'] == 'this') $this->config['author'] = $_REQUEST["user"]; if ($this->config['not_author'] == 'this') $this->config['not_author'] = $_REQUEST["user"]; if ($this->config['author'] || $this->config['not_author']) { $ignoreAuthors = ($this->config['not_author']) ? 'NOT ' : ''; $authorsArr = ($this->config['not_author']) ? $this->config['not_author'] : $this->config['author']; $wheres[] = $ignoreAuthors.'autor regexp "[[:<:]]('.str_replace(',', '|', $authorsArr).')[[:>:]]"'; } // Фильтрация новостей по ДОПОЛНИТЕЛЬНЫМ ПОЛЯМ if ($this->config['xfilter'] || $this->config['not_xfilter']) { $ignoreXfilters = ($this->config['not_xfilter']) ? 'NOT ' : ''; $xfiltersArr = ($this->config['not_xfilter']) ? $this->config['not_xfilter'] : $this->config['xfilter']; $wheres[] = $ignoreXfilters.'xfields regexp "[[:<:]]('.str_replace(',', '|', $xfiltersArr).')[[:>:]]"'; } // Разбираемся с временными рамками отбора новостей, если кол-во дней указано - ограничиваем выборку, если нет - выводим без ограничения даты if(intval($this->config['day'])) $wheres[] = 'date >= "'.$tooday.'" - INTERVAL ' . intval($this->config['day']) . ' DAY'; // Условие для отображения только тех постов, дата публикации которых уже наступила $wheres[] = 'date < "'.$tooday.'"'; // Условие для фильтрации текущего id // $wheres[] = 'id != '.$this->config['postId']; // Складываем условия $where = implode(' AND ', $wheres); // Направление сортировки по убыванию или возрастанию $ordering = $this->config['order'] == 'new'?'DESC':'ASC'; // Сортировка новостей switch ($this->config['sort']) { case 'date': // Дата $sort = 'date '; break; case 'rating': // Рейтинг $sort = 'rating '; break; case 'comms': // Комментарии $sort = 'comm_num '; break; case 'views': // Просмотры $sort = 'news_read '; break; case 'random': // Случайные $sort = 'RAND() '; break; default: // Топ как в DLE (сортировка по умолчанию) $sort = 'rating '.$ordering.', comm_num '.$ordering.', news_read '; break; } // Формирование запроса в зависимости от версии движка if ($newVersion) { // 9.6 и выше $selectRows = 'p.id, p.autor, p.date, p.short_story, p.full_story, p.xfields, p.title, p.category, p.alt_name, p.allow_comm, p.comm_num, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes'; } else { // старые версии $selectRows = '*'; //пока старые версии курят в сторонке } /** * Service function - take params from table * @param $table string - название таблицы * @param $fields string - необходимые поля через запятйю или * для всех * @param $where string - условие выборки * @param $multirow bool - забирать ли один ряд или несколько * @param $start int - начальное значение выборки * @param $limit int - количество записей для выборки, 0 - выбрать все * @param $sort string - поле, по которому осуществляется сортировка * @param $sort_order - направление сортировки * @return array с данными или false если mysql вернуль 0 рядов */ //$news = $this->load_table (PREFIX."_post", $fields = "*", $where = '1', $multirow = false, $start = 0, $limit = 10, $sort = '', $sort_order = 'desc'); $news = $this->load_table (PREFIX . '_post p LEFT JOIN ' . PREFIX . '_post_extras e ON (p.id=e.news_id)', $selectRows, $where, true, $this->config['start_from'], $this->config['limit'], $sort, $ordering); if(empty($news)) $news = array(); // Задаём переменную, в котоую будем всё складывать $output = ''; // Если в выборке нет новостей - сообщаем об этом if (empty($news)) { $output .= '<span style="color: #f00">По заданным критериям материалов нет, попробуйте изменить параметры строки подключения</span>'; return; } // Пробегаем по массиву с новостями и формируем список foreach ($news as $newsItem) { $xfields = xfieldsload(); $newsItem['date'] = strtotime($newsItem['date']); // Формируем ссылки на категории и иконки категорий $my_cat = array(); $my_cat_icon = array(); $my_cat_link = array(); $cat_list = explode(',', $newsItem['category']); foreach($cat_list as $element) { if(isset($this->cat_info[$element])) { $my_cat[] = $this->cat_info[$element]['name']; if ($this->cat_info[$element]['icon']) $my_cat_icon[] = '<img class="bp-cat-icon" src="'.$this->cat_info[$element]['icon'].'" alt="'.$this->cat_info[$element]['name'].'" />'; else $my_cat_icon[] = '<img class="bp-cat-icon" src="{THEME}/blockpro/'.$this->config['noicon'].'" alt="'.$this->cat_info[$element]['name'].'" />'; if( $this->dle_config['allow_alt_url'] == 'yes' ) $my_cat_link[] = '<a href="'.$this->dle_config['http_home_url'].get_url($element).'/">'.$this->cat_info[$element]['name'].'</a>'; else $my_cat_link[] = '<a href="'.$PHP_SELF.'?do=cat&category='.$this->cat_info[$element]['alt_name'].'">'.$this->cat_info[$element]['name'].'</a>'; } } $categoryUrl = ($newsItem['category']) ? $this->dle_config['http_home_url'] . get_url(intval($newsItem['category'])) . '/' : '/' ; // Ссылка на профиль юзера if( $this->dle_config['allow_alt_url'] == 'yes' ) { $go_page = $config['http_home_url'].'user/'.urlencode($newsItem['autor']).'/'; } else { $go_page = $PHP_SELF.'?subaction=userinfo&user='******'autor']); } // Выводим картинку switch($this->config['image']) { // Изображение из дополнительного поля case 'short_story': $imgArray = $this->getImage($newsItem['short_story'], $newsItem['date']); break; // Первое изображение из полного описания case 'full_story': $imgArray = $this->getImage($newsItem['full_story'], $newsItem['date']); break; // По умолчанию - первое изображение из краткой новости default: $xfieldsdata = xfieldsdataload($newsItem['xfields'], $newsItem['date']); if(!empty($xfieldsdata) && !empty($xfieldsdata[$this->config['image']])) { $imgArray = getImage($xfieldsdata[$this->config['image']]); } break; } // Определяем переменные, выводящие картинку $image = ($imgArray['imgResized']) ? $imgArray['imgResized'] : '{THEME}/blockpro/'.$this->config['noimage']; if (!$imgArray['imgResized']) { $imageFull = '{THEME}/blockpro/'.$this->config['noimage_full']; } else { $imageFull = $imgArray['imgOriginal']; } // Формируем вид даты новости для вывода в шаблон if(date('Ymd', $newsItem['date']) == date('Ymd')) { $showDate = $this->dle_lang['time_heute'].langdate(', H:i', $newsItem['date']); } elseif(date('Ymd', $newsItem['date']) == date('Ymd') - 1) { $showDate = $this->dle_lang['time_gestern'].langdate(', H:i', $newsItem['date']); } else { $showDate = langdate($this->dle_config['timestamp_active'], $newsItem['date']); } /** * Код, формирующий вывод шаблона новости */ $tpl->copy_template = preg_replace("#\{date=(.+?)\}#ie", "langdate('\\1', '{$newsItem['date']}')", $tpl->copy_template ); $output .= $this->applyTemplate($this->config['template'], array( '{title}' => $newsItem['title'], '{full-link}' => $this->getPostUrl($newsItem), '{image}' => $image, '{image_full}' => $imageFull, '{short-story}' => $this->textLimit($newsItem['short_story'], $this->config['text_limit']), '{full-story}' => $this->textLimit($newsItem['full_story'], $this->config['text_limit']), '{link-category}' => implode(', ', $my_cat_link), '{category}' => implode(', ', $my_cat), '{category-icon}' => implode('', $my_cat_icon), '{category-url}' => $categoryUrl, '{news-id}' => $newsItem['id'], '{author}' => "<a onclick=\"ShowProfile('" . urlencode( $newsItem['autor'] ) . "', '" . $go_page . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\" href=\"" . $go_page . "\">" . $newsItem['autor'] . "</a>", '{login}' => $newsItem['autor'], '[profile]' => '<a href="'.$go_page.'">', '[/profile]' => '</a>', '[com-link]' => $newsItem['allow_comm']?'<a href="'.$this->getPostUrl($newsItem).'#comment">':'', '[/com-link]' => $newsItem['allow_comm']?'</a>':'', '{comments-num}' => $newsItem['allow_comm']?$newsItem['comm_num']:'', '{views}' => $newsItem['news_read'], '{date}' => $showDate, '{rating}' => $newsItem['allow_rate']?ShowRating( $newsItem['id'], $newsItem['rating'], $newsItem['vote_num'], 0 ):'', '{vote-num}' => $newsItem['allow_rate']?$newsItem['vote_num']:'', ), array( // "'\[show_name\\](.*?)\[/show_name\]'si" => !empty($name)?"\\1":'', // "'\[show_description\\](.*?)\[/show_description\]'si" => !empty($description)?"\\1":'', "'\[comments\\](.*?)\[/comments\]'si" => $newsItem['comm_num']!=='0'?'\\1':'', "'\[not-comments\\](.*?)\[/not-comments\]'si" => $newsItem['comm_num']=='0'?'\\1':'', "'\[rating\\](.*?)\[/rating\]'si" => $newsItem['allow_rate']?'\\1':'', "'\[allow-comm\\](.*?)\[/allow-comm\]'si" => $newsItem['allow_comm']?'\\1':'', "'\[not-allow-comm\\](.*?)\[/not-allow-comm\]'si" => !$newsItem['allow_comm']?'\\1':'', // не уверен, но можно попробовать //"'{title limit=\"(.*?)\"}'esi" => 'dle_substr(striptags($newsItem[\'title\']),0,\\1,$this->config[\'charset\'])', ) ); } // Cохраняем в кэш по данной конфигурации если nocache false if(!$this->config['nocache']) { create_cache($this->config['prefix'].'bp_'.md5(implode('_', $this->config)), $output); } // Выводим содержимое модуля $this->showOutput($output); }
function custom_users($matches = array()) { global $db, $_TIME, $config, $lang, $user_group, $user_conf, $news_date, $member_id, $nav; if (!count($matches)) { return ""; } $yes_no_map = array("yes" => "1", "no" => "0"); $param_str = trim($matches[1]); $thisdate = strtotime(date("Y-m-d H:i:s", $_TIME)); $where = array(); if (preg_match("#template=['\"](.+?)['\"]#i", $param_str, $match)) { $comm_tpl = trim($match[1]); } else { return ""; } if (preg_match("#id=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $where_id = array(); $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $value = explode('-', $value); $where_id[] = "u.user_id >= '" . intval($value[0]) . "' AND u.user_id <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "u.user_id IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $custom_id; } } if (preg_match("#group=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $where_id = array(); $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $value = explode('-', $value); $where_id[] = "u.user_group >= '" . intval($value[0]) . "' AND u.user_group <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "u.user_group IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $custom_id; } } if (preg_match("#online=['\"](.+?)['\"]#i", $param_str, $match)) { if ($match[1] == "yes") { $where[] = "u.lastdate+1200 > {$_TIME} "; } else { $where[] = "u.lastdate+1200 <= {$_TIME} "; } } if (preg_match("#from=['\"](.+?)['\"]#i", $param_str, $match)) { $user_from = intval($match[1]); $custom_all = $custom_from; } else { $user_from = 0; $custom_all = 0; } if (preg_match("#limit=['\"](.+?)['\"]#i", $param_str, $match)) { $user_limit = intval($match[1]); } else { $user_limit = $config['comm_nummers']; } if (preg_match("#order=['\"](.+?)['\"]#i", $param_str, $match)) { $allowed_order = array('news' => 'news_num', 'comment' => 'comm_num', 'group' => 'user_group', 'lastdate' => 'lastdate', 'regdate' => 'reg_date', 'nick' => 'name', 'rand' => 'RAND()'); if ($allowed_order[$match[1]]) { $user_order = $allowed_order[$match[1]]; } } if (!$user_order) { $user_order = "reg_date"; } if (preg_match("#sort=['\"](.+?)['\"]#i", $param_str, $match)) { $allowed_sort = array('asc' => 'ASC', 'desc' => 'DESC'); if ($allowed_sort[$match[1]]) { $user_sort = $allowed_sort[$match[1]]; } } if (!$user_sort) { $user_order = "ASC"; } if (preg_match("#cache=['\"](.+?)['\"]#i", $param_str, $match)) { $user_cache = $yes_no_map[$match[1]]; } else { $user_cache = "0"; } if (preg_match("#not=['\"](.+?)['\"]#i", $param_str, $match)) { $not_found = $db->safesql($match[1]); } else { $not_found = ""; } if (preg_match("#friends=['\"](.+?)['\"]#i", $param_str, $match)) { $fids = array(); if ($match[1] == "current") { $friend_que = $db->query("SELECT friend_id FROM " . PREFIX . "_users_friends WHERE user_id = '{$member_id['user_id']}' AND approve = '1'"); while ($row = $db->get_row($friend_que)) { $fids[] = $row['friend_id']; } } else { if ($match[1] == "profile") { $friend_que = $db->query("SELECT f.friend_id FROM " . PREFIX . "_users_friends f LEFT JOIN " . PREFIX . "_users u ON ( u.user_id = f.user_id ) WHERE u.name = '{$_REQUEST['user']}' AND f.approve = '1'"); while ($row = $db->get_row($friend_que)) { $fids[] = $row['friend_id']; } } } if (count($fids) > 0) { $where[] = "u.user_id IN ('" . implode("','", $fids) . "')"; } else { $where[] = "u.user_id = '0'"; } } else { $user_friends = false; } if (preg_match("#xfield=['\"](.+?)['\"]#i", $param_str, $match)) { $_temp = explode(",", $match[1]); $_rules = array(); foreach ($_temp as $_temp2) { if (strpos($_temp2, "this.") !== False && isset($member_id)) { $_temp3 = explode(":", $_temp2); $_temp4 = trim(str_replace("this.", "", $_temp3[1])); unset($_temp3); $_thisxf = xfieldsdataload($member_id['xfields']); if (array_key_exists($_temp4, $_thisxf)) { $_rules[] = "u.xfields LIKE '%" . $_temp4 . "|" . $_thisxf[$_temp4] . "%'"; } } else { $_rules[] = "u.xfields LIKE '%" . str_replace(":", "|", $_temp2) . "%'"; } } if (count($_rules) > 0) { $where[] = "( " . implode(" AND ", $_rules) . " )"; $use_xfield = True; } } else { $use_xfield = False; } $user_yes = false; $user_cols = array("email", "name", "user_id", "news_num", "comm_num", "user_group", "lastdate", "reg_date", "signature", "foto", "fullname", "land", "logged_ip"); if ($user_conf['sel_xfields']) { $user_cols[] = "xfields"; } $_WHERE = count($where) > 0 ? " WHERE " . implode(' AND ', $where) : ""; $build_navigation = false; if (isset($_GET['cstart'])) { $cstart = intval($_GET['cstart']); } else { $cstart = 0; } if (preg_match("#navigation=['\"](.+?)['\"]#i", $param_str, $match)) { if ($match[1] == "yes" and $url_page !== false) { $build_navigation = true; $custom_limit = $user_limit; //if ( $cstart > 10 ) $config['allow_cache'] = false; if ($cstart) { $cstart = $cstart - 1; $cstart = $cstart * $custom_limit + $user_from; $user_from = $cstart; } $count_que = $db->super_query("SELECT COUNT(u.name) as total FROM " . PREFIX . "_users u{$_WHERE} ORDER BY {$user_order} {$user_sort}"); $count_all = $count_que['total']; } else { $build_navigation = false; } } else { $build_navigation = false; } $user_sql = "SELECT u." . implode(", u.", $user_cols) . " FROM " . PREFIX . "_users u{$_WHERE} ORDER BY {$user_order} {$user_sort} LIMIT {$user_from},{$user_limit}"; $user_que = $db->query($user_sql); if ($user_cache) { $user_cacheid = $param_str . $user_sql . $member_id['user_group'] . $build_navigation . $cstart . implode("|", $user_conf); $cache_content = dle_cache("news_ucustom", $user_cacheid, true); } else { $cache_content = false; } if (!$cache_content) { $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; // Build navigation - start $url_page =& $nav['url_page']; $user_query =& $nav['user_query']; if ($build_navigation and $count_all) { $tpl->load_template('navigation.tpl'); $no_prev = false; $no_next = false; if (isset($_GET['cstart'])) { $cstart = intval($_GET['cstart']); } else { $cstart = 1; } if (isset($cstart) and $cstart != "" and $cstart > 1) { $prev = $cstart - 1; if ($config['allow_alt_url']) { $prev_page = $prev == 1 ? $url_page . "/" : $url_page . "/page/" . $prev . "/"; $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a href=\"" . $prev_page . "\">\\1</a>"); } else { $prev_page = $prev == 1 ? $PHP_SELF . "?" . $user_query : $PHP_SELF . "?cstart=" . $prev . "&" . $user_query; $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a href=\"" . $prev_page . "\">\\1</a>"); } } else { $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<span>\\1</span>"); $no_prev = TRUE; } if ($custom_limit) { $pages = ""; if ($count_all > $custom_limit) { $enpages_count = @ceil($count_all / $custom_limit); if ($enpages_count <= 10) { for ($j = 1; $j <= $enpages_count; $j++) { if ($j != $cstart) { if ($config['allow_alt_url']) { $pages .= $j == 1 ? "<a href=\"" . $url_page . "/\">{$j}</a> " : "<a href=\"" . $url_page . "/page/" . $j . "/\">{$j}</a>"; } else { $pages .= $j == 1 ? "<a href=\"{$PHP_SELF}?{$user_query}\">{$j}</a> " : "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$j}\">{$j}</a>"; } } else { $pages .= "<span>{$j}</span> "; } } } else { $start = 1; $end = 10; $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; if ($cstart > 0) { if ($cstart > 6) { $start = $cstart - 4; $end = $start + 8; if ($end >= $enpages_count) { $start = $enpages_count - 9; $end = $enpages_count - 1; $nav_prefix = ""; } else { $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; } } } if ($start >= 2) { $pages .= $config['allow_alt_url'] ? "<a href=\"" . $url_page . "/\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> " : "<a href=\"{$PHP_SELF}?{$user_query}\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; } for ($j = $start; $j <= $end; $j++) { if ($j != $cstart) { if ($config['allow_alt_url']) { $pages .= $j == 1 ? "<a href=\"" . $url_page . "/\">{$j}</a> " : "<a href=\"" . $url_page . "/page/" . $j . "/\">{$j}</a> "; } else { $pages .= $j == 1 ? "<a href=\"{$PHP_SELF}?{$user_query}\">{$j}</a> " : "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$j}\">{$j}</a> "; } } else { $pages .= "<span>{$j}</span> "; } } if ($cstart != $enpages_count) { $pages .= $config['allow_alt_url'] ? $nav_prefix . "<a href=\"" . $url_page . "/page/{$enpages_count}/\">{$enpages_count}</a>" : $nav_prefix . "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$enpages_count}\">{$enpages_count}</a>"; } else { $pages .= "<span>{$enpages_count}</span> "; } } } $tpl->set('{pages}', $pages); } if ($custom_limit and $custom_limit < $count_all and $cstart < $enpages_count) { $next_page = $cstart + 1; $next = $config['allow_alt_url'] ? $url_page . '/page/' . $next_page . '/' : $PHP_SELF . "?" . $user_query . "&cstart=" . $next_page; $tpl->set_block("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a href=\"" . $next . "\">\\1</a>"); } else { $tpl->set_block("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>"); $no_next = TRUE; } if (!$no_prev or !$no_next) { $tpl->compile('navi'); } $tpl->clear(); } // Build navigation - end $tpl->load_template($comm_tpl . '.tpl'); while ($user_row = $db->get_row($user_que)) { $user_yes = true; $news_row = false; if ($user_conf['sel_news_info']) { $news_row = $db->super_query("SELECT id, title, category, alt_name, date FROM " . PREFIX . "_post WHERE autor = '{$user_row['name']}' ORDER BY date DESC LIMIT 0,1"); if ($news_row) { if (preg_match("#\\{news-title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) { $count = intval($matches[1]); $tpl->set($matches[0], user_title($count, $news_row['title'])); } else { $tpl->set('{news-title}', strip_tags(stripslashes($news_row['title']))); } $tpl->set('{news-link}', user_fulllink($news_row['post_id'], $news_row['category'], $news_row['alt_name'], $news_row['pdate'])); $tpl->set('{news-cat}', get_categories($news_row['category'])); $news_date = strtotime($news_row['date']); $tpl->copy_template = preg_replace_callback("#\\{news-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{news-date}', $news_row['date']); $tpl->set('{news-id}', $news_row['id']); } } if ($user_row['lastdate'] + 1200 > $_TIME) { $tpl->set('[online]', ""); $tpl->set('[/online]', ""); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); } else { $tpl->set('[offline]', ""); $tpl->set('[/offline]', ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } $news_date = $user_row['reg_date']; $tpl->copy_template = preg_replace_callback("#\\{reg-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{reg-date}', date("d.m.Y H:i:s", $news_date)); $news_date = $user_row['lastdate']; $tpl->copy_template = preg_replace_callback("#\\{last-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{last-date}', date("d.m.Y H:i:s", $news_date)); if (count(explode("@", $user_row['foto'])) == 2) { $tpl->set('{foto}', 'http://www.gravatar.com/avatar/' . md5(trim($user_row['foto'])) . '?s=' . intval($user_group[$user_row['user_group']]['max_foto'])); } else { if ($user_row['foto'] && $config['version_id'] < "10.5") { if (file_exists(ROOT_DIR . "/uploads/fotos/" . $user_row['foto'])) { $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $comm_row['foto']); } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } } else { if ($user_row['foto'] && $config['version_id'] >= "10.5") { $tpl->set('{foto}', $user_row['foto']); } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } } } if ($user_conf['sel_xfields']) { $xf = xfieldsdataload($user_row['xfields']); foreach ($xf as $xf_key => $xf_val) { $xf_key = preg_quote($xf_key, "'"); $tpl->set("{xfield-" . $xf_key . "}", $xf_val); } } else { $tpl->set_block("'{xfield-(.*?)}'si", ""); } $tpl->set("{name}", $user_row['name']); $tpl->set("{name-colored}", $user_group[$user_row['user_group']]['group_prefix'] . $user_row['name'] . $user_group[$user_row['user_group']]['group_suffix']); $tpl->set("{name-url}", $config['allow_alt_url'] ? $config['http_home_url'] . "user/" . urlencode($user_row['name']) : $config['http_home_url'] . "index.php?subaction=userinfo&user="******"{name-popup}", $config['allow_alt_url'] ? "ShowProfile('" . urlencode($user_row['name']) . "', '" . $config['http_home_url'] . "user/" . urlencode($user_row['name']) . "/', '1'); return false;" : "ShowProfile('" . urlencode($user_row['name']) . "', '" . $config['http_home_url'] . "index.php?subaction=userinfo&user="******"', '0'); return false;"); $tpl->set("{allnews-url}", $config['allow_alt_url'] ? $config['http_home_url'] . "user/" . urlencode($user_row['name']) . "/news/" : $config['http_home_url'] . "index.php?subaction=allnews&user="******"{allcomm-url}", $config['http_home_url'] . "index.php?do=lastcomments&userid=" . urlencode($user_row['user_id'])); $tpl->set("{pm-url}", $config['http_home_url'] . "index.php?do=pm&doaction=newpm&user="******"{email-url}", $config['http_home_url'] . "index.php?do=feedback&user="******"{news-num}", intval($user_row['news_num'])); $tpl->set("{comm-num}", intval($user_row['comm_num'])); $tpl->set("{email}", $user_row['email']); $tpl->set("{ip}", $user_row['logged_ip']); $tpl->set("{id}", $user_row['user_id']); $tpl->set("{land}", $user_row['land']); $tpl->set('{info}', $user_row['info']); $tpl->set('{sign}', $user_row['signature']); $tpl->set("{full-name}", $user_row['fullname']); $tpl->set("{group}", $user_group[$user_row['user_group']]['group_name']); $tpl->set("{group-id}", $user_group[$user_row['user_group']]['id']); $tpl->set("{group-colored}", $user_group[$user_row['user_group']]['group_prefix'] . $user_group[$user_row['user_group']]['group_name'] . $user_group[$user_row['user_group']]['group_suffix']); $tpl->set("{group-icon}", $user_group[$user_row['user_group']]['icon']); $tpl->compile("content"); $tpl->result['content'] = preg_replace("#\\{xfield-(.*?)\\}#is", "", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[user-group=" . $user_row['user_group'] . "\\](.*?)\\[/user-group\\]#is", "\\1", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[user-group=([0-9])\\](.*?)\\[/user-group\\]#is", "", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[news\\](.*?)\\[/news\\]#is", $news_row != false ? "\\1" : "", $tpl->result['content']); } if (!$user_yes) { $tpl->result['content'] = $not_found; } if ($build_navigation) { $tpl->result['content'] = $tpl->result['content'] . $tpl->result['navi']; } $tpl->result['content'] = str_replace("{THEME}", $config['http_home_url'] . "templates/" . $config['skin'] . "/", $tpl->result['content']); if ($user_cache) { create_cache("news_ucustom", $tpl->result['content'], $user_cacheid, true); } return $tpl->result['content']; } else { return $cache_content; } }