Example #1
0
/**
 * Find the main htaccess file for the site and check whether the rules of the
 * main htaccess file of the site are the default rules generated by WordPress.
 *
 * @return string The HTML code displaying the information about the HTAccess rules.
 */
function sucuriscan_infosys_htaccess()
{
    $htaccess_path = SucuriScan::get_htaccess_path();
    $template_variables = array('HTAccess.Content' => '', 'HTAccess.Message' => '', 'HTAccess.MessageType' => '', 'HTAccess.MessageVisible' => 'hidden', 'HTAccess.TextareaVisible' => 'hidden');
    if ($htaccess_path) {
        $htaccess_rules = file_get_contents($htaccess_path);
        $template_variables['HTAccess.MessageType'] = 'updated';
        $template_variables['HTAccess.MessageVisible'] = 'visible';
        $template_variables['HTAccess.TextareaVisible'] = 'visible';
        $template_variables['HTAccess.Content'] = $htaccess_rules;
        $template_variables['HTAccess.Message'] .= 'HTAccess file found in this path <code>' . $htaccess_path . '</code>';
        if (empty($htaccess_rules)) {
            $template_variables['HTAccess.TextareaVisible'] = 'hidden';
            $template_variables['HTAccess.Message'] .= '</p><p>The HTAccess file found is completely empty.';
        }
        if (sucuriscan_htaccess_is_standard($htaccess_rules)) {
            $template_variables['HTAccess.Message'] .= '</p><p>
                The main <code>.htaccess</code> file in your site has the standard rules for a WordPress installation. You can customize it to improve the
                performance and change the behaviour of the redirections for pages and posts in your site. To get more information visit the official documentation at
                <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29" target="_blank">Codex WordPrexx - Creating and editing (.htaccess)</a>';
        }
    } else {
        $template_variables['HTAccess.Message'] = 'Your website does not contains a <code>.htaccess</code> file or it was not found in the default location.';
        $template_variables['HTAccess.MessageType'] = 'error';
        $template_variables['HTAccess.MessageVisible'] = 'visible';
    }
    return SucuriScanTemplate::get_section('infosys-htaccess', $template_variables);
}
Example #2
0
/**
 * Find the main htaccess file for the site and check whether the rules of the
 * main htaccess file of the site are the default rules generated by WordPress.
 *
 * @return string The HTML code displaying the information about the HTAccess rules.
 */
function sucuriscan_infosys_htaccess()
{
    $htaccess_path = SucuriScan::get_htaccess_path();
    $params = array('HTAccess.Content' => '', 'HTAccess.TextareaVisible' => 'hidden', 'HTAccess.StandardVisible' => 'hidden', 'HTAccess.NotFoundVisible' => 'hidden', 'HTAccess.FoundVisible' => 'hidden', 'HTAccess.Fpath' => 'unknown');
    if ($htaccess_path) {
        $htaccess_rules = @file_get_contents($htaccess_path);
        $params['HTAccess.TextareaVisible'] = 'visible';
        $params['HTAccess.Content'] = $htaccess_rules;
        $params['HTAccess.Fpath'] = $htaccess_path;
        $params['HTAccess.FoundVisible'] = 'visible';
        if (sucuriscan_htaccess_is_standard($htaccess_rules)) {
            $params['HTAccess.StandardVisible'] = 'visible';
        }
    } else {
        $params['HTAccess.NotFoundVisible'] = 'visible';
    }
    return SucuriScanTemplate::getSection('infosys-htaccess', $params);
}