phpMyFAQ /phpmyfaq/admin/stat.search.php

Language PHP Lines 148
MD5 Hash bc047450ca73d1eefd424bf65d0bfb65
Repository https://github.com/cyrke/phpMyFAQ.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
 * Frontend for search log statistics
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Anatoliy Belsky <anatoliy.belsky@mayflower.de>
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2003-2012 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2003-03-30
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

if ($permission['viewlog']) {

    printf('<header><h2>%s</h2></header>', $PMF_LANG['ad_menu_searchstats']);

    $perpage = 15;
    $pages   = PMF_Filter::filterInput(INPUT_GET, 'pages', FILTER_VALIDATE_INT);
    $page    = PMF_Filter::filterInput(INPUT_GET, 'page' , FILTER_VALIDATE_INT, 1);
    
    $search        = new PMF_Search($faqConfig);
    $searchesCount = $search->getSearchesCount();
    $searchesList  = $search->getMostPopularSearches($searchesCount + 1, true);
    
    if (is_null($pages)) {
        $pages = round((count($searchesList) + ($perpage / 3)) / $perpage, 0);
    }
    
    $start = ($page - 1) * $perpage;
    $ende  = $start + $perpage;

    $baseUrl = sprintf(
        '%s?action=searchstats&amp;page=%d',
        PMF_Link::getSystemRelativeUri(),
        $page
    );

    // Pagination options
    $options = array(
        'baseUrl'         => $baseUrl,
        'total'           => count($searchesList),
        'perPage'         => $perpage,
        'pageParamName'   => 'page'
    );
    $pagination = new PMF_Pagination($faqConfig, $options);
?>
        <div id="ajaxresponse"></div>
        <table class="table table-striped">
        <thead>
        <tr>
            <th><?php print $PMF_LANG['ad_searchstats_search_term'] ?></th>
            <th><?php print $PMF_LANG['ad_searchstats_search_term_count'] ?></th>
            <th><?php print $PMF_LANG['ad_searchstats_search_term_lang'] ?></th>
            <th colspan="2"><?php print $PMF_LANG['ad_searchstats_search_term_percentage'] ?></th>
            <th>&nbsp;</th>
        </tr>
        </thead>
        <tfoot>
            <tr>
                <td colspan="6"><?php echo $pagination->render(); ?></td>
            </tr>
        </tfoot>
        <tbody>
<?php 

    $counter = $displayedCounter = 0;
    $self    = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']));

    foreach($searchesList as $searchItem) {

        if ($displayedCounter >= $perpage) {
            $displayedCounter++;
            continue;
        }

        $counter++;
        if ($counter <= $start) {
            continue;
        }
        $displayedCounter++;
        
        $num = round(($searchItem['number']*100 / $searchesCount), 2);
?>
        <tr class="row_search_id_<?php print $searchItem['id'] ?>">
            <td><?php print PMF_String::htmlspecialchars($searchItem['searchterm']);  ?></td>
            <td><?php print $searchItem['number'] ?></td>
            <td><?php print $languageCodes[PMF_String::strtoupper($searchItem['lang'])] ?></td>
            <td>
                <div class="progress progress-info" style="width: 50px;">
                    <div class="bar" style="width: <?php print $num; ?>%;"></div>
                </div>
            </td>
            <td><?php print $num; ?>%</td>
            <td>
                <a onclick="deleteSearchTerm('<?php print $searchItem['searchterm'] ?>', <?php print $searchItem['id'] ?>); return false;"
                   href="javascript:;">
                    <span title="<?php print $PMF_LANG["ad_news_delete"]; ?>" class="icon-trash"></span>
                </a>
            </td>
        </tr>
<?php
    }
?>
        </tbody>
        </table>
        <script type="text/javascript">
        /* <![CDATA[ */
        /**
         * Ajax call to delete search term
         *
         * @param searchterm
         */
        function deleteSearchTerm(searchterm, searchId)
        {
            if (confirm('<?php print $PMF_LANG['ad_user_del_3'] ?>')) {
                $.getJSON("index.php?action=ajax&ajax=search&ajaxaction=delete_searchterm&searchterm=" + searchterm,
                function(response) {
                    if (response == 1) {
                        $('#ajaxresponse').
                            html('<?php printf('<p class="success">%s</p>', $PMF_LANG['ad_search_delsuc']) ?>');
                        $('.row_search_id_' + searchId).fadeOut('slow');
                    } else {
                        $('#ajaxresponse').
                            html('<?php printf('<p class="error">%s</p>', $PMF_LANG['ad_search_delfail']) ?>');
                    }
                });
            }
        }
        /* ]]> */
        </script>
<?php 

} else {
    print $PMF_LANG['err_NotAuth'];
}
Back to Top