} if ($cat_info[$row['category']]['icon']) { $tpl->set('{category-icon}', $cat_info[$row['category']]['icon']); } else { $tpl->set('{category-icon}', "{THEME}/dleimages/no_icon.gif"); } if ($row['category']) { $tpl->set('{category-url}', $config['http_home_url'] . get_url($row['category']) . "/"); } else { $tpl->set('{category-url}', "#"); } if ($row['allow_rate']) { if ($config['short_rating'] and $user_group[$member_id['user_group']]['allow_rating']) { $tpl->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], 1)); } else { $tpl->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], 0)); } $tpl->set('{vote-num}', $row['vote_num']); $tpl->set('[rating]', ""); $tpl->set('[/rating]', ""); } else { $tpl->set('{rating}', ""); $tpl->set('{vote-num}', ""); $tpl->set_block("'\\[rating\\](.*?)\\[/rating\\]'si", ""); } if ($config['allow_alt_url'] == "yes") { $go_page = $config['http_home_url'] . "user/" . urlencode($row['autor']) . "/"; $tpl->set('[day-news]', "<a href=\"" . $config['http_home_url'] . date('Y/m/d/', $row['date']) . "\" >"); } else { $go_page = "{$PHP_SELF}?subaction=userinfo&user="******"<a href=\"{$PHP_SELF}?year=" . date('Y', $row['date']) . "&month=" . date('m', $row['date']) . "&day=" . date('d', $row['date']) . "\" >");
</ul> <div class="indent"></div> </div> <div><a href="javascript:void(0)" ><div class="icn_sml_sphere"></div><div class="tag_title">Fields</div></a></div> <div class="LeftMenuRow"> <ul class="LeftMenuRow_Inner"> <?php ShowRating("Tags_SA", 30, $Tags); ?> </ul> <div class="indent"></div> </div> <div><a href="javascript:void(0)" ><div class="icn_sml_music"></div><div class="tag_title">Music</div></a></div> <div class="LeftMenuRow"> <ul class="LeftMenuRow_Inner"> <?php ShowRating("Tags_Music", 30, $Tags); mysql_close(); ?> </ul> <div class="indent"></div> </div> <!--<div><a href="javascript:void(0)" ><div class="icn_sml_worldmap"></div><div class="tag_title">World Map</div></a></div> <div class="LeftMenuRow"></div> <div><a href="javascript:void(0)" ><div class="icn_sml_authors"></div><div class="tag_title">Authors</div></a></div> <div class="LeftMenuRow"></div>-->
$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['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 ($row['allow_rate']) { $tpl->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'])); $tpl->set('{vote-num}', "<span id=\"vote-num-id-" . $row['id'] . "\">" . $row['vote_num'] . "</span>"); $tpl->set('[rating]', ""); $tpl->set('[/rating]', ""); if ($user_group[$member_id['user_group']]['allow_rating']) { if ($config['rating_type']) { $tpl->set('[rating-plus]', "<a href=\"#\" onclick=\"doRate('plus', '{$row['id']}'); return false;\" >"); $tpl->set('[/rating-plus]', '</a>'); if ($config['rating_type'] == "2") { $tpl->set('[rating-minus]', "<a href=\"#\" onclick=\"doRate('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", "");
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); }
$member_id['name'] = $db->safesql($member_id['name']); if ($is_logged) { $where = "member = '{$member_id['name']}'"; } else { $where = "ip ='{$_IP}'"; } $row = $db->super_query("SELECT news_id FROM " . PREFIX . "_logs WHERE news_id ='{$news_id}' AND {$where}"); if (!$row['news_id'] and count(explode(".", $_IP)) == 4) { $db->query("UPDATE " . PREFIX . "_post_extras SET rating=rating+'{$go_rate}', vote_num=vote_num+1 WHERE news_id ='{$news_id}'"); if ($db->get_affected_rows()) { if ($is_logged) { $user_name = $member_id['name']; } else { $user_name = "noname"; } $db->query("INSERT INTO " . PREFIX . "_logs (news_id, ip, member) values ('{$news_id}', '{$_IP}', '{$user_name}')"); if ($config['allow_alt_url'] == "yes" and !$config['seo_type']) { $cprefix = "full_"; } else { $cprefix = "full_" . $news_id; } clear_cache(array('news_', 'rss', $cprefix)); } } $row = $db->super_query("SELECT news_id, rating, vote_num FROM " . PREFIX . "_post_extras WHERE news_id ='{$news_id}'"); $buffer = ShowRating($row['news_id'], $row['rating'], $row['vote_num'], false); $buffer = addcslashes($buffer, "\t\n\r\"\\/"); $buffer = htmlspecialchars("{\"success\":true, \"rating\":\"{$buffer}\", \"votenum\":\"{$row['vote_num']}\"}", ENT_NOQUOTES, $config['charset']); $db->close(); @header("Content-type: text/html; charset=" . $config['charset']); echo $buffer;
$Tags_SA = ReadAndExplode("Tags_SA"); $Tags_Fashion = ReadAndExplode("Tags_Fashion"); $Tags_Arts = ReadAndExplode("Tags_Arts"); $Tags_Music = ReadAndExplode("Tags_Music"); $Tags_Others = ReadAndExplode("Tags_Others"); //подсчет количества ключевых слов по каждой категории $num_Tags_SA = count($Tags_SA); $num_Tags_Fashion = count($Tags_Fashion); $num_Tags_Arts = count($Tags_Arts); $num_Tags_Music = count($Tags_Music); $num_Tags_Others = count($Tags_Others); //находим максимальную категорию $numMax = max($num_Tags_SA, $num_Tags_Fashion, $num_Tags_Arts, $num_Tags_Music, $num_Tags_Others); //Очистка таблицы $droptQuery = "TRUNCATE TABLE u186876_tvarts.tags"; mysql_query($droptQuery); //помещаем все значения колонок в u186876_tvarts.tags в одном общем цикле for ($x = 0; $x < $numMax; $x++) { $insertQuery_Tags = "INSERT INTO u186876_tvarts.tags (Tags_SA, Tags_Fashion, Tags_Arts, Tags_Music, Tags_Others) VALUES ('{$Tags_SA[$x]}', '{$Tags_Fashion[$x]}', '{$Tags_Arts[$x]}', '{$Tags_Music[$x]}', '{$Tags_Others[$x]}')"; mysql_query($insertQuery_Tags); $mysql_error = mysql_error(); echo '<br />' . $mysql_error . '<br />'; } } echo "<table><tr>"; ShowRating("Tags_SA", 30); ShowRating("Tags_Fashion", 10); ShowRating("Tags_Arts", 10); ShowRating("Tags_Music", 10); ShowRating("Tags_Others", 10); echo "</tr></table>";