function hookAdminStatsModules() { if (Tools::isSubmit('submitTruncatePNF')) { Db::getInstance()->Execute('TRUNCATE `' . _DB_PREFIX_ . 'pagenotfound`'); $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" /> ' . $this->l('Pages not found has been emptied.') . '</div>'; } $this->_html .= '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>'; if (!file_exists(dirname(__FILE__) . '/../../.htaccess')) { $this->_html .= '<div class="warning warn">' . $this->l('You <b>must</b> use a .htaccess file to redirect 404 errors to the page "404.php"') . '</div>'; } $pages = $this->getPages(); if (sizeof($pages)) { $this->_html .= ' <table class="table" cellpadding="0" cellspacing="0"> <tr> <th width="200">' . $this->l('Page') . '</th> <th width="500">' . $this->l('Referrer') . '</th> <th>' . $this->l('Counter') . '</th> </tr>'; foreach ($pages as $ru => $hrs) { foreach ($hrs as $hr => $counter) { if ($hr != 'nb') { $this->_html .= ' <tr> <td><a href="' . $ru . '-admin404">' . wordwrap($ru, 30, '<br />', true) . '</a></td> <td><a href="' . Tools::getProtocol() . $hr . '">' . wordwrap($hr, 40, '<br />', true) . '</a></td> <td align="right">' . $counter . '</td> </tr>'; } } } $this->_html .= ' </table>'; } else { $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" /> ' . $this->l('No pages registered') . '</div>'; } $this->_html .= '</fieldset>'; if (sizeof($pages)) { $this->_html .= '<div class="clear"> </div> <fieldset class="width3"><legend><img src="../img/admin/delete.gif" /> ' . $this->l('Empty database') . '</legend> <form action="' . Tools::htmlEntitiesUtf8($_SERVER['REQUEST_URI']) . '" method="post"><input type="submit" class="button" name="submitTruncatePNF" value="' . $this->l('Empty ALL pages not found') . '"></form> </fieldset>'; } $this->_html .= '<div class="clear"> </div> <fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend> <h2>' . $this->l('404 errors') . '</h2> <p>' . $this->l('A 404 error is an HTTP error code which means that the file requested by the user cannot be found. In your case it means that one of your visitors entered a wrong URL in the address bar or that you or another website has a dead link. When it is available, the referrer is shown so you can find the page which contains the dead link. If not, it means generally that it is a direct access, so someone may have bookmarked a link which doesn\'t exist anymore.') . '</p> <h3>' . $this->l('How to catch these errors?') . '</h3> <p>' . $this->l('If your webhost supports the <i>.htaccess</i> file, you can create it in the root directory of PrestaShop and insert the following line inside:') . ' <i>ErrorDocument 404 ' . __PS_BASE_URI__ . '404.php</i>. ' . $this->l('A user requesting a page which doesn\'t exist will be redirected to the page.') . ' <i>' . __PS_BASE_URI__ . '404.php</i>. ' . $this->l('This module logs the accesses to this page: the page requested, the referrer and the number of times that it occurred.') . '</p><br /> </fieldset>'; return $this->_html; }
public function hookAdminStatsModules() { if (Tools::isSubmit('submitTruncatePNF')) { Db::getInstance()->execute('TRUNCATE `' . _DB_PREFIX_ . 'pagenotfound`'); $this->html .= '<div class="alert alert-warning"> ' . $this->l('The "pages not found" cache has been emptied.') . '</div>'; } else { if (Tools::isSubmit('submitDeletePNF')) { Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'pagenotfound` WHERE date_add BETWEEN ' . ModuleGraph::getDateBetween()); $this->html .= '<div class="alert alert-warning"> ' . $this->l('The "pages not found" cache has been deleted.') . '</div>'; } } $this->html .= ' <div class="panel-heading"> ' . $this->displayName . ' </div> <h4>' . $this->l('Guide') . '</h4> <div class="alert alert-warning"> <h4>' . $this->l('404 errors') . '</h4> <p>' . $this->l('A 404 error is an HTTP error code which means that the file requested by the user cannot be found. In your case it means that one of your visitors entered a wrong URL in the address bar, or that you or another website has a dead link. When possible, the referrer is shown so you can find the page/site which contains the dead link. If not, it generally means that it is a direct access, so someone may have bookmarked a link which doesn\'t exist anymore.') . ' </p> <p> </p> <h4>' . $this->l('How to catch these errors?') . '</h4> <p>' . sprintf($this->l('If your webhost supports .htaccess files, you can create one in the root directory of PrestaShop and insert the following line inside: "%s".'), 'ErrorDocument 404 ' . __PS_BASE_URI__ . '404.php') . '<br />' . sprintf($this->l('A user requesting a page which doesn\'t exist will be redirected to the following page: %s. This module logs access to this page.'), __PS_BASE_URI__ . '404.php') . ' </p> </div>'; if (!file_exists($this->_normalizeDirectory(_PS_ROOT_DIR_) . '.htaccess')) { $this->html .= '<div class="alert alert-warning">' . $this->l('You must use a .htaccess file to redirect 404 errors to the "404.php" page.') . '</div>'; } $pages = $this->getPages(); if (count($pages)) { $this->html .= ' <table class="table"> <thead> <tr> <th><span class="title_box active">' . $this->l('Page') . '</span></th> <th><span class="title_box active">' . $this->l('Referrer') . '</span></th> <th><span class="title_box active">' . $this->l('Counter') . '</span></th> </tr> </thead> <tbody>'; foreach ($pages as $ru => $hrs) { foreach ($hrs as $hr => $counter) { if ($hr != 'nb') { $this->html .= ' <tr> <td><a href="' . $ru . '-admin404">' . wordwrap($ru, 30, '<br />', true) . '</a></td> <td><a href="' . Tools::getProtocol() . $hr . '">' . wordwrap($hr, 40, '<br />', true) . '</a></td> <td>' . $counter . '</td> </tr>'; } } } $this->html .= ' </tbody> </table>'; } else { $this->html .= '<div class="alert alert-warning"> ' . $this->l('No "page not found" issue registered for now.') . '</div>'; } if (count($pages)) { $this->html .= ' <h4>' . $this->l('Empty database') . '</h4> <form action="' . Tools::htmlEntitiesUtf8($_SERVER['REQUEST_URI']) . '" method="post"> <button type="submit" class="btn btn-default" name="submitDeletePNF"> <i class="icon-remove"></i> ' . $this->l('Empty ALL "pages not found" notices for this period') . ' </button> <button type="submit" class="btn btn-default" name="submitTruncatePNF"> <i class="icon-remove"></i> ' . $this->l('Empty ALL "pages not found" notices') . ' </button> </form>'; } return $this->html; }