function get_search_results($query, $start, $category, $searchtype, $results, $domain)
{
    global $sph_messages, $results_per_page, $links_to_next, $show_query_scores, $desc_length;
    if ($results != "") {
        $results_per_page = $results;
    }
    if ($searchtype == "phrase") {
        $query = str_replace('"', '', $query);
        $query = "\"" . $query . "\"";
    }
    $starttime = getmicrotime();
    // catch " if only one time entered
    $query = preg_replace("/"/", "\"", $query);
    if (substr_count($query, '"') == 1) {
        $query = str_replace('"', '', $query);
    }
    $words = makeboollist($query);
    if (isset($words['ignore'])) {
        $ignorewords = $words['ignore'];
    } else {
        $ignorewords = "";
    }
    $full_result['ignore_words'] = $ignorewords;
    if ($start == 0) {
        $start = 1;
    }
    $result = search($words, $category, $start, $results_per_page, $searchtype, $domain);
    $query = stripslashes($query);
    $entitiesQuery = htmlspecialchars($query);
    $full_result['ent_query'] = $entitiesQuery;
    $endtime = getmicrotime() - $starttime;
    if (isset($result['results'])) {
        $rows = $result['results'];
    } else {
        $rows = "";
    }
    $time = round($endtime * 100) / 100;
    $full_result['time'] = $time;
    $did_you_mean = array();
    $did_you_mean_b = array();
    if (isset($result['did_you_mean']) && is_array($result['did_you_mean'])) {
        while (list($key, $alt) = each($result['did_you_mean'])) {
            $entities = html_to_latin1(utf8_decode($entitiesQuery));
            if ($key != $alt) {
                $alt = html_to_latin1(utf8_decode($alt));
                $alt = sanitize($alt);
                $entities = preg_replace("/"/", "\"", $entities);
                if ($alt[0] == "/") {
                    /* this indicates that the search word is not found and there is no close alternative either */
                    $alt = substr($alt, 1);
                    $did_you_mean_b[] = latin1_to_html(str_ireplace($key, "<strike>{$alt}</strike>", $entities));
                    $did_you_mean[] = str_ireplace($key, "", $entities);
                } else {
                    $did_you_mean_b[] = latin1_to_html(str_ireplace($key, "<b>{$alt}</b>", $entities));
                    $did_you_mean[] = str_ireplace($key, utf8_encode($alt), $entities);
                }
            }
        }
    }
    $full_result['did_you_mean'] = $did_you_mean;
    $full_result['did_you_mean_b'] = $did_you_mean_b;
    $matchword = $sph_messages["matches"];
    if ($rows == 1) {
        $matchword = $sph_messages["match"];
    }
    $num_of_results = count($result) - 2;
    $full_result['num_of_results'] = $num_of_results;
    if ($start < 2) {
        saveToLog($query, $time, $rows);
    }
    $from = ($start - 1) * $results_per_page + 1;
    $to = min($start * $results_per_page, $rows);
    $full_result['from'] = $from;
    $full_result['to'] = $to;
    $full_result['total_results'] = $rows;
    if ($rows > 0) {
        $maxweight = $result['maxweight'];
        $i = 0;
        while ($i < $num_of_results && $i < $results_per_page) {
            if (!isset($result[$i]['url'])) {
                $i++;
                continue;
            }
            $url = $result[$i]['url'];
            $title = isset($result[$i]['title']) ? $result[$i]['title'] : "";
            $summary = $result[$i]['summary'];
            $lang = $result[$i]['lang'];
            $fulltxt = $result[$i]['fulltxt'];
            $page_size = $result[$i]['size'];
            $domain = $result[$i]['domain'];
            if ($page_size != "") {
                $page_size = number_format($page_size, 1) . "kb";
            }
            $txtlen = strlen($fulltxt);
            if ($txtlen > $desc_length) {
                $places = array();
                foreach ($words['hilight'] as $word) {
                    $word = latin1_to_html($word);
                    $tmp = strtolower($fulltxt);
                    $found_in = strpos($tmp, $word);
                    $sum = -strlen($word);
                    while (!($found_in == '')) {
                        $pos = $found_in + strlen($word);
                        $sum += $pos;
                        //FIX!!
                        $tmp = substr($tmp, $pos);
                        $places[] = $sum;
                        $found_in = strpos($tmp, $word);
                    }
                }
                sort($places);
                $x = 0;
                $begin = 0;
                $end = 0;
                while (list($id, $place) = each($places)) {
                    while (isset($places[$id + $x]) && $places[$id + $x] - $place < $desc_length && $x + $id < count($places) && $place < strlen($fulltxt) - $desc_length) {
                        $x++;
                        $begin = $id;
                        $end = $id + $x;
                    }
                }
                if (!isset($places[$begin])) {
                    $places[$begin] = 0;
                }
                $begin_pos = max(0, $places[$begin] - 30);
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                if ($places[$begin] > 0) {
                    $begin_pos = strpos($fulltxt, " ");
                }
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                $fulltxt = substr($fulltxt, 0, strrpos($fulltxt, " "));
                $fulltxt = $fulltxt;
            }
            $weight = number_format($result[$i]['weight'] / $maxweight * 100, 2);
            if ($title == '') {
                /* for an untitled document, use the filename without the path */
                $pos = strrpos($url, "/");
                if ($pos >= 0) {
                    $pos++;
                } else {
                    $pos = 0;
                }
                $title = substr($url, $pos);
            }
            $regs = array();
            if (strlen($title) > 80) {
                $title = substr($title, 0, 76) . "...";
            }
            foreach ($words['hilight'] as $change) {
                $change = latin1_to_html($change);
                $count = 0;
                while (preg_match("/[ .,;\\(\\)\\'\"](" . $change . ")[ .,;\\(\\)\\'\"]/i", " " . $title . " ", $regs) && ++$count < 20) {
                    $title = preg_replace("/([ .,;\\(\\)\\'\"])" . $regs[1] . "([ .,;\\(\\)\\'\"])/i", "\$1<b>" . $regs[1] . "</b>\$2", $title);
                }
                $count = 0;
                while (preg_match("/[ .,;\\(\\)\\'\"](" . $change . ")[ .,\\(\\)\\'\"]/i", " " . $fulltxt . " ", $regs) && ++$count < 20) {
                    $fulltxt = preg_replace("/([ .,;\\(\\)\\'\"])" . $regs[1] . "([ .,;\\(\\)\\'\"])/i", "\$1<b>" . $regs[1] . "</b>\$2", $fulltxt);
                }
            }
            $num = $from + $i;
            $full_result['qry_results'][$i]['num'] = $num;
            $full_result['qry_results'][$i]['weight'] = $weight;
            $full_result['qry_results'][$i]['url'] = $url;
            $full_result['qry_results'][$i]['title'] = $title;
            $full_result['qry_results'][$i]['summary'] = $summary;
            $full_result['qry_results'][$i]['lang'] = $lang;
            $full_result['qry_results'][$i]['fulltxt'] = $fulltxt;
            $full_result['qry_results'][$i]['page_size'] = $page_size;
            $full_result['qry_results'][$i]['domain_name'] = $domain;
            $i++;
        }
    }
    $pages = ceil($rows / $results_per_page);
    $full_result['pages'] = $pages;
    $prev = $start - 1;
    $full_result['prev'] = $prev;
    $next = $start + 1;
    $full_result['next'] = $next;
    $full_result['start'] = $start;
    $full_result['query'] = $entitiesQuery;
    if ($from <= $to) {
        $firstpage = $start - $links_to_next;
        if ($firstpage < 1) {
            $firstpage = 1;
        }
        $lastpage = $start + $links_to_next;
        if ($lastpage > $pages) {
            $lastpage = $pages;
        }
        for ($x = $firstpage; $x <= $lastpage; $x++) {
            $full_result['other_pages'][] = $x;
        }
    }
    return $full_result;
}
示例#2
0
function get_search_results($query, $start, $category, $searchtype, $results, $domain)
{
    global $sph_messages, $results_per_page, $links_to_next, $show_query_scores, $mysql_table_prefix, $desc_length;
    if ($results != "") {
        $results_per_page = $results;
    }
    if ($searchtype == "phrase") {
        $query = str_replace('"', '', $query);
        $query = "\"" . $query . "\"";
    }
    $starttime = getmicrotime();
    // catch " if only one time entered
    if (substr_count($query, '"') == 1) {
        $query = str_replace('"', '', $query);
    }
    $words = makeboollist($query);
    $ignorewords = $words['ignore'];
    $full_result['ignore_words'] = $words['ignore'];
    if ($start == 0) {
        $start = 1;
    }
    $result = search($words, $category, $start, $results_per_page, $searchtype, $domain);
    $query = stripslashes($query);
    $entitiesQuery = htmlspecialchars($query);
    $full_result['ent_query'] = $entitiesQuery;
    $endtime = getmicrotime() - $starttime;
    $rows = $result['results'];
    $time = round($endtime * 100) / 100;
    $full_result['time'] = $time;
    $did_you_mean = "";
    if (isset($result['did_you_mean'])) {
        $did_you_mean_b = $entitiesQuery;
        $did_you_mean = $entitiesQuery;
        while (list($key, $val) = each($result['did_you_mean'])) {
            if ($key != $val) {
                $did_you_mean_b = str_replace($key, "<b>{$val}</b>", $did_you_mean_b);
                $did_you_mean = str_replace($key, "{$val}", $did_you_mean);
            }
        }
    }
    $full_result['did_you_mean'] = $did_you_mean;
    $full_result['did_you_mean_b'] = $did_you_mean_b;
    $matchword = $sph_messages["matches"];
    if ($rows == 1) {
        $matchword = $sph_messages["match"];
    }
    $num_of_results = count($result) - 2;
    $full_result['num_of_results'] = $num_of_results;
    if ($start < 2) {
        saveToLog(addslashes($query), $time, $rows);
    }
    $from = ($start - 1) * $results_per_page + 1;
    $to = min($start * $results_per_page, $rows);
    $full_result['from'] = $from;
    $full_result['to'] = $to;
    $full_result['total_results'] = $rows;
    if ($rows > 0) {
        $maxweight = $result['maxweight'];
        $i = 0;
        while ($i < $num_of_results && $i < $results_per_page) {
            $title = $result[$i]['title'];
            $url = $result[$i]['url'];
            $fulltxt = $result[$i]['fulltxt'];
            $page_size = $result[$i]['size'];
            $domain = $result[$i]['domain'];
            if ($page_size != "") {
                $page_size = number_format($page_size, 1) . "kb";
            }
            $txtlen = strlen($fulltxt);
            if ($txtlen > $desc_length) {
                $places = array();
                foreach ($words['hilight'] as $word) {
                    $tmp = strtolower($fulltxt);
                    $found_in = strpos($tmp, $word);
                    $sum = -strlen($word);
                    while (!($found_in == '')) {
                        $pos = $found_in + strlen($word);
                        $sum += $pos;
                        //FIX!!
                        $tmp = substr($tmp, $pos);
                        $places[] = $sum;
                        $found_in = strpos($tmp, $word);
                    }
                }
                sort($places);
                $x = 0;
                $begin = 0;
                $end = 0;
                while (list($id, $place) = each($places)) {
                    while ($places[$id + $x] - $place < $desc_length && $x + $id < count($places) && $place < strlen($fulltxt) - $desc_length) {
                        $x++;
                        $begin = $id;
                        $end = $id + $x;
                    }
                }
                $begin_pos = max(0, $places[$begin] - 30);
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                if ($places[$begin] > 0) {
                    $begin_pos = strpos($fulltxt, " ");
                }
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                $fulltxt = substr($fulltxt, 0, strrpos($fulltxt, " "));
                $fulltxt = $fulltxt;
            }
            $weight = number_format($result[$i]['weight'] / $maxweight * 100, 2);
            if ($title == '') {
                $title = $sph_messages["Untitled"];
            }
            $regs = array();
            if (strlen($title) > 80) {
                $title = substr($title, 0, 76) . "...";
            }
            foreach ($words['hilight'] as $change) {
                while (preg_match("/[^\\>](" . $change . ")[^\\<]/i", " " . $title . " ", $regs)) {
                    $title = preg_replace("/" . $regs[1] . "/i", "<b>" . $regs[1] . "</b>", $title);
                }
                while (preg_match("/[^\\>](" . $change . ")[^\\<]/i", " " . $fulltxt . " ", $regs)) {
                    $fulltxt = preg_replace("/" . $regs[1] . "/i", "<b>" . $regs[1] . "</b>", $fulltxt);
                }
                $url2 = $url;
                while (preg_match("/[^\\>](" . $change . ")[^\\<]/i", $url2, $regs)) {
                    $url2 = preg_replace("/" . $regs[1] . "/i", "<b>" . $regs[1] . "</b>", $url2);
                }
            }
            $num = $from + $i;
            $full_result['qry_results'][$i]['num'] = $num;
            $full_result['qry_results'][$i]['weight'] = $weight;
            $full_result['qry_results'][$i]['url'] = $url;
            $full_result['qry_results'][$i]['title'] = $title;
            $full_result['qry_results'][$i]['fulltxt'] = $fulltxt;
            $full_result['qry_results'][$i]['url2'] = $url2;
            $full_result['qry_results'][$i]['page_size'] = $page_size;
            $full_result['qry_results'][$i]['domain_name'] = $domain;
            $i++;
        }
    }
    $pages = ceil($rows / $results_per_page);
    $full_result['pages'] = $pages;
    $prev = $start - 1;
    $full_result['prev'] = $prev;
    $next = $start + 1;
    $full_result['next'] = $next;
    $full_result['start'] = $start;
    $full_result['query'] = $entitiesQuery;
    if ($from <= $to) {
        $firstpage = $start - $links_to_next;
        if ($firstpage < 1) {
            $firstpage = 1;
        }
        $lastpage = $start + $links_to_next;
        if ($lastpage > $pages) {
            $lastpage = $pages;
        }
        for ($x = $firstpage; $x <= $lastpage; $x++) {
            $full_result['other_pages'][] = $x;
        }
    }
    return $full_result;
}
示例#3
0
function get_search_results($query, $start, $category, $searchtype, $results, $domain)
{
    global $sph_messages, $results_per_page, $all_wild, $show_meta_description, $title_length, $links_to_next, $wildsearch, $show_warning, $mark, $type, $show_query_scores, $index_host, $url_length, $query_hits, $mysql_table_prefix, $desc_length, $utf8, $case_sensitive;
    if ($results != "") {
        $results_per_page = $results;
    }
    if ($searchtype == "phrase") {
        $query = str_replace('"', '', $query);
        $query = "\"" . $query . "\"";
    }
    if ($utf8 == 1 && $case_sensitive == 0 && $searchtype != "phrase") {
        $query = lower_case($query);
    }
    $starttime = getmicrotime();
    // catch " if only one time entered
    if (substr_count($query, '"') == 1) {
        $query = str_replace('"', '', $query);
    }
    $words = makeboollist($query);
    $ignorewords = $words['ignore'];
    $full_result['ignore_words'] = $words['ignore'];
    if ($start == 0) {
        $start = 1;
    }
    $result = search($words, $category, $start, $results_per_page, $searchtype, $domain);
    $query = stripslashes($query);
    $entitiesQuery = htmlspecialchars(str_replace("\"", "", $query));
    $full_result['ent_query'] = $entitiesQuery;
    $endtime = getmicrotime() - $starttime;
    $rows = $result['results'];
    $time = round($endtime * 100) / 100;
    $full_result['time'] = $time;
    $did_you_mean = "";
    if (isset($result['did_you_mean'])) {
        $did_you_mean_b = $entitiesQuery;
        $did_you_mean = $entitiesQuery;
        while (list($key, $val) = each($result['did_you_mean'])) {
            if ($key != $val) {
                $did_you_mean_b = str_replace($key, "<b>{$val}</b>", $did_you_mean_b);
                $did_you_mean = str_replace($key, "{$val}", $did_you_mean);
            }
        }
    }
    $full_result['did_you_mean'] = $did_you_mean;
    $full_result['did_you_mean_b'] = $did_you_mean_b;
    $matchword = $sph_messages["matches"];
    if ($rows == 1) {
        $matchword = $sph_messages["match"];
    }
    $num_of_results = count($result) - 2;
    $full_result['num_of_results'] = $num_of_results;
    if ($start < 2) {
        saveToLog(addslashes($query), $time, $rows);
    }
    $from = ($start - 1) * $results_per_page + 1;
    $to = min($start * $results_per_page, $rows);
    $full_result['from'] = $from;
    $full_result['to'] = $to;
    $full_result['total_results'] = $rows;
    if ($rows > 0) {
        $maxweight = $result['maxweight'];
        $i = 0;
        while ($i < $num_of_results && $i < $results_per_page) {
            $title = $result[$i]['title'];
            $url = $result[$i]['url'];
            $fulltxt = $result[$i]['fulltxt'];
            $page_size = $result[$i]['size'];
            $domain = $result[$i]['domain'];
            if ($page_size != "") {
                $page_size = number_format($page_size, 1) . " kb";
            }
            //  If available, enable part of a word highlighting in result report
            if ($all_wild) {
                $words = makeboollist($all_wild);
            }
            $txtlen = strlen($fulltxt);
            //$refreshed = ereg_replace("[*!]", '',trim($query)); //  works also for *wildcard search
            if ($show_meta_description === 1 || $txtlen > $desc_length) {
                $places = array();
                $strictpos = strpos($query, '!');
                if ($strictpos === 0) {
                    // if !strict search enter here
                    if ($case_sensitive == '1') {
                        $recovered = str_replace('!', '', trim($query));
                        $tmp = $fulltxt;
                    } else {
                        $recovered = str_replace('!', '', trim(lower_case($query)));
                        $tmp = lower_case($fulltxt);
                    }
                    $words['hilight'][0] = "{$recovered}";
                    //  replace without ' ! '
                    $strict_length = strlen($recovered);
                    $found_in = '1';
                    //  pointer position start
                    $pos_absolut = '0';
                    foreach ($words['hilight'] as $word) {
                        while (!($found_in == '')) {
                            $found_in = strpos($tmp, $word);
                            $tmp_front = substr($tmp, $found_in - 1);
                            //  one character before found match position
                            $pos = $found_in + strlen($word);
                            $pos_absolut = $pos_absolut + $found_in;
                            $tmp = substr($tmp, $pos);
                            //  get rest of fulltxt
                            //  check weather found match is realy strict
                            $found_before = preg_match("/[(a-z)-_*.\\/\\:&@\\w]/", substr($tmp_front, 0, 1));
                            $found_behind = preg_match("/[(a-z)-_*.,\\/\\:&@\\w]/", substr($tmp, 0, 1));
                            if ($found_before === 0 && $found_behind === 0) {
                                $places[] = $pos_absolut;
                                //  remind absolut position of match
                                $found_in = '';
                            }
                        }
                    }
                } else {
                    // if not !strict search enter here (standard search)
                    foreach ($words['hilight'] as $word) {
                        if ($case_sensitive == '0') {
                            $tmp = lower_case($fulltxt);
                            $word = lower_case($word);
                        } else {
                            $tmp = $fulltxt;
                        }
                        $found_in = strpos($tmp, $word);
                        $sum = -strlen($word);
                        while (!($found_in == '')) {
                            $pos = $found_in + strlen($word);
                            $sum += $pos;
                            //FIX!!
                            $tmp = substr($tmp, $pos);
                            $places[] = $sum;
                            $found_in = strpos($tmp, $word);
                        }
                    }
                }
                sort($places);
                $x = 0;
                $begin = 0;
                $end = 0;
                while (list($id, $place) = each($places)) {
                    while ($places[$id + $x] - $place < $desc_length && $x + $id < count($places) && $place < strlen($fulltxt) - $desc_length) {
                        $x++;
                        $begin = $id;
                        $end = $id + $x;
                    }
                }
                $begin_pos = max(0, $places[$begin] - 80);
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                if ($places[$begin] > 0) {
                    $begin_pos = strpos($fulltxt, " ");
                }
                $fulltxt = substr($fulltxt, $begin_pos, $desc_length);
                $fulltxt = substr($fulltxt, 0, strrpos($fulltxt, " "));
                $fulltxt = $fulltxt;
            }
            if ($query_hits == '0') {
                //  calculate percentage of weight
                $weight = number_format($result[$i]['weight'] / $maxweight * 100, 1);
            } else {
                $weight = number_format($result[$i]['weight']);
            }
            if ($title == '') {
                $title = $sph_messages["Untitled"];
            }
            $regs = array();
            if (strlen($title) > $title_length) {
                // if necessary shorten length of title in result page
                $length_tot = strpos($title, " ", $title_length);
                // find end of last word for shortened title
                if ($length_tot) {
                    $title = substr($title, 0, $length_tot) . " ...";
                }
            }
            $url2 = $url;
            if (strlen($url) > $url_length) {
                // if necessary shorten length of URL in result page
                $url2 = substr($url, 0, $url_length) . "...";
            }
            if ($places[0] == '' && $query_hits == 1 && $type != 'tol') {
                //  if nothing found in HTML text and query hits as result output
                $weight = '0';
            }
            if ($places[0] == '' && $show_warning == '1' && $type != 'tol' || $show_warning == '1' && $weight == '0') {
                // if  no HTML text to highlight
                $warnmessage = $sph_messages['showWarning'];
                $fulltxt = "<span class='warn'>{$warnmessage}</span>";
            }
            if ($mark == 'markbold') {
                $highlight = "span class='mak_1'";
            }
            if ($mark == 'markblue') {
                $highlight = "span class='mak_2'";
            }
            if ($mark == 'markyellow') {
                $highlight = "span class='mak_3'";
            }
            if ($mark == 'markgreen') {
                $highlight = "span class='mak_4'";
            }
            foreach ($words['hilight'] as $change) {
                if (!($strictpos === 0)) {
                    //  no marking in title and url if strict search
                    if ($case_sensitive == '1') {
                        //  if we have to search case sensetive, enter here
                        while (@ereg("[^\\>](" . $change . ")[^\\<]", " " . $title . " ", $regs)) {
                            $title = ereg_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $title);
                        }
                        if ($index_host == '1') {
                            while (@ereg("[^\\>](" . $change . ")[^\\<]", $url2, $regs)) {
                                $url2 = ereg_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $url2);
                            }
                        }
                    } else {
                        // mark upper and lower case match
                        while (@eregi("[^\\>](" . $change . ")[^\\<]", " " . $title . " ", $regs)) {
                            $title = eregi_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $title);
                        }
                        if ($index_host == '1') {
                            while (@eregi("[^\\>](" . $change . ")[^\\<]", $url2, $regs)) {
                                $url2 = eregi_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $url2);
                            }
                        }
                    }
                }
                if ($strictpos === 0) {
                    //      if strict search mark only the real result with blanks before and behind
                    $change = " {$change} ";
                }
                if ($case_sensitive == '1') {
                    //  mark fulltext case sensitive
                    while (@ereg("[^\\>](" . $change . ")[^\\<]", " " . $fulltxt . " ", $regs)) {
                        $fulltxt = ereg_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $fulltxt);
                    }
                } else {
                    //      mark all in fulltext
                    while (@eregi("[^\\>](" . $change . ")[^\\<]", " " . $fulltxt . " ", $regs)) {
                        $fulltxt = eregi_replace($regs[1], "<{$highlight}>" . $regs[1] . "</span>", $fulltxt);
                    }
                }
            }
            $places = array();
            $num = $from + $i;
            $full_result['qry_results'][$i]['num'] = $num;
            $full_result['qry_results'][$i]['weight'] = $weight;
            $full_result['qry_results'][$i]['url'] = $url;
            $full_result['qry_results'][$i]['title'] = $title;
            $full_result['qry_results'][$i]['fulltxt'] = $fulltxt;
            $full_result['qry_results'][$i]['url2'] = $url2;
            $full_result['qry_results'][$i]['page_size'] = $page_size;
            $full_result['qry_results'][$i]['domain_name'] = $domain;
            $i++;
        }
    }
    $pages = ceil($rows / $results_per_page);
    $full_result['pages'] = $pages;
    $prev = $start - 1;
    $full_result['prev'] = $prev;
    $next = $start + 1;
    $full_result['next'] = $next;
    $full_result['start'] = $start;
    $full_result['query'] = $entitiesQuery;
    if ($from <= $to) {
        $firstpage = $start - $links_to_next;
        if ($firstpage < 1) {
            $firstpage = 1;
        }
        $lastpage = $start + $links_to_next;
        if ($lastpage > $pages) {
            $lastpage = $pages;
        }
        for ($x = $firstpage; $x <= $lastpage; $x++) {
            $full_result['other_pages'][] = $x;
        }
    }
    return $full_result;
}