Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('DATALIFEENGINE')) {
- die("Hacking attempt!");
- }
- include ENGINE_DIR . '/data/searchclouddata.php';
- require_once ENGINE_DIR . '/classes/search.class.php';
- $search = new Searchcloud();
- if (!$tpl->result['search_cloud']) {
- $counts = array();
- $tags = array();
- $list = array();
- $sizes = array(
- "clouds_xsmall",
- "clouds_small",
- "clouds_medium",
- "clouds_large",
- "clouds_xlarge"
- );
- $min = 1;
- $max = 1;
- $range = 1;
- if ($searchcloud['order'] == "1") {
- $order = "datetime DESC";
- }
- if ($searchcloud['order'] == "2") {
- $order = "tag DESC";
- }
- if ($searchcloud['order'] == "3") {
- $order = "RAND()";
- }
- $db->query("SELECT SQL_CALC_FOUND_ROWS tag, COUNT(*) AS count FROM " . PREFIX . "_search GROUP BY tag ORDER BY {$order} LIMIT 0,{$searchcloud['limit']}");
- while ($row = $db->get_row()) {
- $tags[$row['tag']] = $row['count'];
- $counts[] = $row['count'];
- }
- $db->free();
- if (count($counts)) {
- $min = min($counts);
- $max = max($counts);
- $range = ($max - $min);
- }
- if (!$range)
- $range = 1;
- foreach ($tags as $tag => $value) {
- $list[$tag]['tag'] = $tag;
- $list[$tag]['size'] = $sizes[sprintf("%d", ($value - $min) / $range * 4)];
- $list[$tag]['count'] = $value;
- $char_mixed = $search->ddlrandom($searchcloud['alpha'], $searchcloud['numeric'], $search->CHAR_ALPHA . $search->CHAR_NUMERIC, $list);
- $list[$tag]['mixed'] = $char_mixed;
- }
- $tags = array();
- foreach ($list as $value) {
- if (dle_strlen($value['tag'], $config['charset']) > $searchcloud['urllimit'])
- $title = dle_substr($value['tag'], 0, $searchcloud['urllimit'], $config['charset']) . " ...";
- else
- $title = $value['tag'];
- if (!$searchcloud['urlpath']) {
- $urlpath = "";
- } else {
- $urlpath = $searchcloud['urlpath'] . "/";
- }
- if ($searchcloud['random'] != "no") {
- $full_link = $config['http_home_url'] . $urlpath . $value['mixed'] . "/" . $search->dleUrlEncode($value['tag']) . ".html";
- } else {
- $full_link = $config['http_home_url'] . $urlpath . $search->dleUrlEncode($value['tag']) . ".html";
- }
- if (trim($value['tag']) != "") {
- if ($config['allow_alt_url'] == "yes")
- $tags[] = "<a href=\"" . $full_link . "\" title=\"" . mb_convert_case($value['tag'], MB_CASE_TITLE, "UTF-8") . "\">" . mb_convert_case($title, MB_CASE_TITLE, "UTF-8") . "</a>";
- else
- $tags[] = "<a href=\"$PHP_SELF?do=search&subaction=search&story=" . $search->dleUrlEncode($value['tag']) . "&searchterm=tag\" title=\"" . $lang['tags_count'] . " " . $value['count'] . "\">" . mb_convert_case($title, MB_CASE_TITLE, "UTF-8") . "</a>";
- }
- }
- $tpl->result['search_cloud'] = implode(", ", $tags);
- $row = $db->super_query("SELECT FOUND_ROWS() as count");
- if ($row['count'] >= $searchcloud['limit']) {
- if ($config['allow_alt_url'] == "yes")
- $tpl->result['search_cloud'] .= ", ...<a href=\"" . $config['http_home_url'] . "searchs\">» Show all search results</a><span style=\"display:none;\"><a href=\"http://www.ddl-turkey.net\">DataLife Engine English Support</a></span>";
- else
- $tpl->result['search_cloud'] .= ", ...<a href=\"$PHP_SELF?do=allsearchs\">» Show all search results</a><span style=\"display:none;\"><a href=\"http://www.ddl-turkey.net\">DataLife Engine English Support</a></span>";
- }
- }
- if ($do == "allsearchs") {
- $tpl->result['content'] = dle_cache("allsearchs", $config['skin']);
- if (!$tpl->result['content']) {
- $tpl->load_template('searchcloud.tpl');
- $counts = array();
- $tags = array();
- $list = array();
- $sizes = array(
- "clouds_xsmall",
- "clouds_small",
- "clouds_medium",
- "clouds_large",
- "clouds_xlarge"
- );
- $min = 1;
- $max = 1;
- $range = 1;
- $db->query("SELECT tag, COUNT(*) AS count FROM " . PREFIX . "_search GROUP BY tag");
- while ($row = $db->get_row()) {
- $tags[$row['tag']] = $row['count'];
- $counts[] = $row['count'];
- }
- $db->free();
- if (count($counts)) {
- $min = min($counts);
- $max = max($counts);
- $range = ($max - $min);
- }
- if (!$range)
- $range = 1;
- foreach ($tags as $tag => $value) {
- $list[$tag]['tag'] = $tag;
- $list[$tag]['size'] = $sizes[sprintf("%d", ($value - $min) / $range * 4)];
- $list[$tag]['count'] = $value;
- $char_mixed = $search->ddlrandom($searchcloud['alpha'], $searchcloud['numeric'], $search->CHAR_ALPHA . $search->CHAR_NUMERIC, $list);
- $list[$tag]['mixed'] = $char_mixed;
- }
- $tags = array();
- foreach ($list as $value) {
- if (!$searchcloud['urlpath']) {
- $urlpath = "";
- } else {
- $urlpath = $searchcloud['urlpath'] . "/";
- }
- if ($searchcloud['random'] != "no") {
- $full_link = $config['http_home_url'] . $urlpath . $value['mixed'] . "/" . $search->dleUrlEncode($value['tag']) . ".html";
- } else {
- $full_link = $config['http_home_url'] . $urlpath . $search->dleUrlEncode($value['tag']) . ".html";
- }
- if (trim($value['tag']) != "") {
- if ($config['allow_alt_url'] == "yes")
- $tags[] = "<a href=\"" . $full_link . "\" class=\"{$value['size']}\" title=\"" . $lang['tags_count'] . " " . $value['count'] . "\">" . mb_convert_case($value['tag'], MB_CASE_TITLE, "UTF-8") . "</a>";
- else
- $tags[] = "<a href=\"$PHP_SELF?do=search&subaction=search&story=" . $search->dleUrlEncode($value['tag']) . "&searchterm=tag\" class=\"{$value['size']}\" title=\"" . $lang['tags_count'] . " " . $value['count'] . "\">" . mb_convert_case($value['tag'], MB_CASE_TITLE, "UTF-8") . "</a>";
- }
- }
- $tags = implode(", ", $tags);
- $tpl->set('{tags}', $tags . '<p align=\"center\" style=\"padding-top:24px;\"><a href=\"http://www.ddl-turkey.net\">Powered by Engine</a></p>');
- $tpl->compile('content');
- $tpl->clear();
- create_cache("allsearchs", $tpl->result['content'], $config['skin']);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement