$settings = array(); $settings["popup"] = $_REQUEST["popup"] ? 1 : 0; $settings["pm"] = $_REQUEST["pm"] ? 1 : 0; $settings["aInterval"] = $aInterval; $settings["iInterval"] = $iInterval; $settings["smileys"] = $_REQUEST["smileys"] ? 1 : 0; $settings["smileySet"] = $smileySet; $settings["format"] = $_REQUEST["format"]; $settings["lastLine"] = $lastLine; if ($settings["pm"] && file_exists(getSettingsPath() . "/chat/nopm")) { if (!unlink(getSettingsPath() . "/chat/nopm")) { $ret = "{ \"error\": theUILang.chatPMError }"; } } elseif (!$settings["pm"]) { if (!touch(getSettingsPath() . "/chat/nopm")) { $ret = "{ \"error\": theUILang.chatPMError }"; } } $chat = new rChat(); if (!$chat->set($settings)) { $ret = "{ \"error\": theUILang.chatSettingsSave }"; } else { $ret = json_encode($chat->get()); } break; } } if (empty($ret)) { $ret = "{ \"error\": theUILang.chatInvalidReq }"; } cachedEcho($ret, "application/json");
<?php require_once "chat.php"; eval(getPluginConf("chat")); $chatDir = getSettingsPath() . "/chat"; if (!file_exists($chatDir) || !is_dir($chatDir)) { mkdir($chatDir); } $chat = rChat::load(); $chatSettings = $chat->get(); $chatList = array(); $chatList["main_chat"] = array(); $chatList["main_chat"]["newChat"] = file_exists($chatDir . "/main_chat.log.new"); $chatList["main_chat"]["disabled"] = false; if ($chatSettings["pm"]) { $me = getUser(); $users = scandir($rootPath . "/share/users/"); if ($users && count($users) > 0) { foreach ($users as $user) { if ($user[0] == "." || $user == $me) { continue; } $chatList[$user] = array(); $chatList[$user]["newChat"] = file_exists($chatDir . "/" . $user . ".log.new"); $chatList[$user]["disabled"] = file_exists($rootPath . "/share/users/" . $user . "/settings/chat/nopm"); } } } $jResult .= "plugin.chatList = " . json_encode($chatList) . ";"; $jResult .= "plugin.settings = " . json_encode($chatSettings) . ";"; $jResult .= "plugin.listInterval = " . $defaultListInterval * 1000 . ";";