2

ファイルのキャッシュを停止しようとしていchatrooms.jsますが、チャットの開発者から、次の方法でオフにする必要があると言われました。js.php

これはのコードですjs.php:

include_once (dirname(__FILE__).DIRECTORY_SEPARATOR.'config.php');

if (phpversion() >= '5') {
    include_once (dirname(__FILE__).DIRECTORY_SEPARATOR.'jsmin.php');
}

if (BAR_DISABLED == 1) { exit; }

if(get_magic_quotes_runtime()) { 
    set_magic_quotes_runtime(false); 
}

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime; 

$HTTP_USER_AGENT = '';
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;

ob_start();

if (!empty($_REQUEST['type']) && !empty($_REQUEST['name'])) {
    $type = cleanInput($_REQUEST['type']);
    $name = cleanInput($_REQUEST['name']);
} else {
    $type = 'core';
    $name = 'default';
}

$cbfn = '';

if (!empty($_REQUEST['callbackfn'])) {
    $cbfn = $_REQUEST['callbackfn'];
} 

if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js') && DEV_MODE != 1) {

    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js')) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }

    readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js');
    $js = ob_get_clean();

} else {

    if (($type != 'core' || $name != 'default') && $type != 'external') {

        if ($type == 'core') {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR.$name.".js");
        } else {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR.$type."s".DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.$name.".js");
        }

    } else {

        if (USE_COMET == 1) {
            $minHeartbeat = REFRESH_BUDDYLIST.'000';
            $maxHeartbeat = REFRESH_BUDDYLIST.'000';
        }

        if ((defined('INCLUDE_JQUERY') && INCLUDE_JQUERY == 1) || !empty($_GET['callbackfn'])) {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."jquery.js");
        }

        $settings = '';

        if ((defined('DISPLAY_ALL_USERS') && DISPLAY_ALL_USERS == 1) || (defined('FORCE_ALL_USERS') && FORCE_ALL_USERS == 1)) {
            $language[14] = $language[28];
        } else if ($hideOffline == 1) {
            $language[14] = $language[29];
        }
        for ($i=0;$i<count($language);$i++) {
        $settings .= "_2[".$i."] = '".str_replace("'", "\'", $language[$i])."';\n";
        }

        for ($i=0;$i<count($trayicon);$i++) {
            $id = $trayicon[$i];
            if (!empty($trayicon[$i][7]) && $trayicon[$i][7] == 1) {
                $trayicon[$i][2] = BASE_URL.$trayicon[$i][2];
            }

            if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR.$trayicon[$i][0].DIRECTORY_SEPARATOR."lang".DIRECTORY_SEPARATOR.$lang.".php")) {
                include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR.$trayicon[$i][0].DIRECTORY_SEPARATOR."lang".DIRECTORY_SEPARATOR.$lang.".php");
                    $traylanguage = $trayicon[$i][0].'_language';

                if (!empty(${$traylanguage}[100])) {
                    $trayicon[$i][1] = ${$traylanguage}[100];
                }
            }

            $settings .= "_3['".$id[0]."'] = ['".implode("','",$trayicon[$i])."'];\n";
        }

        if (!empty($_GET['callbackfn'])) {
            $hideBar = 0;
        }

        $settings .= "var _4 = ['".implode("','",$plugins)."'];\n";
        $settings .= "var _5 = ".$autoPopupChatbox.";";
        $settings .= "var _6 = ".$messageBeep.";";
        $settings .= "var _7 = '".$theme."';";
        $settings .= "var _8 = ".$minHeartbeat.";";
        $settings .= "var _9 = ".$maxHeartbeat.";";
        $settings .= "var _a = '".$cookiePrefix."';";
        $settings .= "var _b = '".$barType."';";
        $settings .= "var _c = ".$barWidth.";";
        $settings .= "var _d = '".$barAlign."';";
        $settings .= "var _e = ".$barPadding.";";
        $settings .= "var _f = ".$beepOnAllMessages.";";
        $settings .= "var _10 = ".$fullName.";";
        $settings .= "var _11 = ".$autoLoadModules.";";
    $settings .= "var _12 = ".$longNameLength.";";
    $settings .= "var _13 = ".$shortNameLength.";";
    $settings .= "var _14 = ".$searchDisplayNumber.";";
    $settings .= "var _15 = ".$thumbnailDisplayNumber.";";
    $settings .= "var _16 = ".$typingTimeout.";";
    $settings .= "var _17 = ".$idleTimeout.";";
    $settings .= "var _18 = ".$displayOfflineNotification.";";
    $settings .= "var _19 = ".$displayOnlineNotification.";";
    $settings .= "var _1a = ".$displayBusyNotification.";";
    $settings .= "var _1b = ".$notificationTime.";";
    $settings .= "var _1c = ".$announcementTime.";";
    $settings .= "var _1d = ".$armyTime.";";
    $settings .= "var _1e = ".$scrollTime.";";
    $settings .= "var _1f = ".$disableForIE6.";";
    $settings .= "var _20 = ".$disableForMobileDevices.";";
    $settings .= "var _21 = ".$iPhoneView.";";
    $settings .= "var _22 = ".$hideBar.";";
    $settings .= "var _23 = ".$fixFlash.";";
    $settings .= "var _24 = ['".implode("','",$extensions)."'];\n";




include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."libraries.js");

        if ($sleekScroller == 1) {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."scroll.js");
        }

        if (USE_COMET == 1) {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."transports".DIRECTORY_SEPARATOR.TRANSPORT.DIRECTORY_SEPARATOR.'config.php');
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."transports".DIRECTORY_SEPARATOR.TRANSPORT.DIRECTORY_SEPARATOR.'includes.php');
        }

        // Modifying this will void license
        if ($p_<2) { $jsfn = 'c5'; } else { $jsfn = 'c6'; }

        if ($lightWeight == 1 && empty($_GET['callbackfn'])) {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."cometchat_lite.js");     
        } else {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."cometchat.js");                                                                                                                     
        }

        if ($type =='external') {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.$name.".js");
        }

        $include = 'init';

        if (!empty($_GET['callbackfn']) && $_GET['callbackfn'] != 'desktop') {
            $include = $_GET['callbackfn'];
        }

        foreach ($plugins as $plugin) {
            if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.$include.".js")) {
                include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.$include.".js");
            }
        }

        foreach ($extensions as $extension) {
            if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR."extensions".DIRECTORY_SEPARATOR.$extension.DIRECTORY_SEPARATOR.$include.".js")) {
                include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."extensions".DIRECTORY_SEPARATOR.$extension.DIRECTORY_SEPARATOR.$include.".js");
            }
        }

        for ($i=0;$i<count($trayicon);$i++) {
            $id = $trayicon[$i];
            if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR.$id[0].DIRECTORY_SEPARATOR."extra.js") && empty($_GET['callbackfn'])) {
                include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR.$id[0].DIRECTORY_SEPARATOR."extra.js");
            }
        }

        if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."extra.js")  && empty($_GET['callbackfn'])) {
            include_once (dirname(__FILE__).DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."extra.js");
        }
    }

    if (phpversion() >= '5') {
        $js = JSMin::minify(ob_get_clean());
    } else {
        $js = ob_get_clean();
    }

    $fp = @fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js', 'w'); 
    @fwrite($fp, $js);
    @fclose($fp);

}

if (phpversion() >= '4.0.4pl1' && (strstr($useragent,'compatible') || strstr($useragent,'Gecko'))) {
    if (extension_loaded('zlib') && GZIP_ENABLED == 1) {
        ob_start('ob_gzhandler');
    } else { ob_start(); }
} else { ob_start(); }

$lastModified = filemtime(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js');

header('Content-type: text/javascript;charset=utf-8');
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
header('Expires: '.gmdate("D, d M Y H:i:s", time() + 3600*24*365).' GMT');

echo $js;

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "\n\n/* Execution time: ".$totaltime." seconds */";

function cleanInput($input) {
    $input = trim($input);
    $input = preg_replace("/[^+A-Za-z0-9\_]/", "", $input); 
    return strtolower($input);
}

キャッシュを無効にするようにここのどこかに指示する必要があります/modules/chatrooms/chatrooms.js

しかし、どこに何を入れるか正確にわかりません..何かアイデアはありますか?

4

1 に答える 1

8

変化する:

header('Expires: '.gmdate("D, d M Y H:i:s", time() + 3600*24*365).' GMT');

に:

header('Expires: '.gmdate("D, d M Y H:i:s", time() - 3600*24*365).' GMT');

このようにして、ファイルは将来ではなく過去に期限切れになります。

更新: @Salman A、小切手を指摘しましたIF-MODIFIED-SINCE。これを行う必要があります:

変化する

if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js')) {

に:

if (0){//!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cbfn.$theme.$lang.$type.$name.'.js')) {

これにより、式が に変わり、そのコード ブロックが無効になります。FALSE再度有効にする必要がある場合は、0){//.

于 2013-01-01T13:40:21.830 に答える