some fixes

This commit is contained in:
kremsy 2013-11-09 19:26:57 +01:00
parent 985340d543
commit d0c0c0c53f
19 changed files with 539 additions and 523 deletions

View File

@ -23,75 +23,10 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf>
<file leaf-file-name="plugin.php" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="core.php" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/core/plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="20" selection-start="307" selection-end="307" vertical-scroll-proportion="-11.769231" vertical-offset="51" max-vertical-offset="2380">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="plugins.ManiaControl.xml" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/configs/plugins.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="11" column="0" selection-start="363" selection-end="363" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="323">
<folding>
<marker date="1384000064631" expanded="true" signature="111:311" placeholder="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="core.ManiaControl.xml" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/configs/core.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="357">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="database.ManiaControl.xml" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/configs/database.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="374">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="core.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/core.php"> <entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="168" column="13" selection-start="3581" selection-end="3581" vertical-scroll-proportion="-3.9605262" vertical-offset="2555" max-vertical-offset="6613"> <state line="117" column="33" selection-start="2501" selection-end="2501" vertical-scroll-proportion="0.6572104" vertical-offset="1433" max-vertical-offset="6647">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ManiaControl.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ManiaControl.php">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.0" vertical-offset="0" max-vertical-offset="544">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="pluginHandler.php" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/core/pluginHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="2" selection-start="484" selection-end="484" vertical-scroll-proportion="0.7243675" vertical-offset="0" max-vertical-offset="751">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="manialinkIdHandler.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/manialinkIdHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="19" column="5" selection-start="306" selection-end="306" vertical-scroll-proportion="-12.423077" vertical-offset="0" max-vertical-offset="748">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -111,17 +46,23 @@
<option value="$PROJECT_DIR$/core/database.ManiaControl.php" /> <option value="$PROJECT_DIR$/core/database.ManiaControl.php" />
<option value="$PROJECT_DIR$/core/manialinkIdHandler.php" /> <option value="$PROJECT_DIR$/core/manialinkIdHandler.php" />
<option value="$PROJECT_DIR$/core/core.ManiaControl.php" /> <option value="$PROJECT_DIR$/core/core.ManiaControl.php" />
<option value="$PROJECT_DIR$/core/plugin.php" />
<option value="$PROJECT_DIR$/configs/plugins.ManiaControl.xml" /> <option value="$PROJECT_DIR$/configs/plugins.ManiaControl.xml" />
<option value="$PROJECT_DIR$/core/core.php" />
<option value="$PROJECT_DIR$/core/pluginHandler.php" /> <option value="$PROJECT_DIR$/core/pluginHandler.php" />
<option value="$PROJECT_DIR$/core/plugin.php" />
<option value="$PROJECT_DIR$/core/server.php" />
<option value="$PROJECT_DIR$/ManiaControl.php" />
<option value="$PROJECT_DIR$/core/commands.php" />
<option value="$PROJECT_DIR$/core/stats.php" />
<option value="$PROJECT_DIR$/core/chat.php" />
<option value="$PROJECT_DIR$/core/callbacks.php" />
<option value="$PROJECT_DIR$/core/core.php" />
</list> </list>
</option> </option>
</component> </component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" /> <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="-8" /> <option name="x" value="618" />
<option name="y" value="-8" /> <option name="y" value="35" />
<option name="width" value="1936" /> <option name="width" value="1936" />
<option name="height" value="1056" /> <option name="height" value="1056" />
</component> </component>
@ -151,18 +92,6 @@
<sortByType /> <sortByType />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope">
<subPane subId="Problems" />
<subPane subId="Tests" />
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<PATH> <PATH>
@ -211,6 +140,18 @@
</PATH> </PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="Scope">
<subPane subId="Problems" />
<subPane subId="Tests" />
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -218,8 +159,8 @@
<property name="WebServerToolWindowFactoryState" value="true" /> <property name="WebServerToolWindowFactoryState" value="true" />
<property name="options.lastSelected" value="reference.settings.ide.settings.uml" /> <property name="options.lastSelected" value="reference.settings.ide.settings.uml" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/.." /> <property name="last_opened_file_path" value="$PROJECT_DIR$/.." />
<property name="options.searchVisible" value="true" />
<property name="options.splitter.details.proportions" value="0.2" /> <property name="options.splitter.details.proportions" value="0.2" />
<property name="options.searchVisible" value="true" />
</component> </component>
<component name="PublishConfig"> <component name="PublishConfig">
<servers> <servers>
@ -283,29 +224,50 @@
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="7" /> <frame x="618" y="35" width="1936" height="1056" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.105790645" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.12540022" sideWeight="0.8942093" order="0" side_tool="false" content_ui="combo" /> <window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.12646745" sideWeight="0.8942093" order="0" side_tool="false" content_ui="combo" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.105790645" sideWeight="0.5" order="8" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
</layout>
<layout-to-restore>
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.105790645" sideWeight="0.5" order="8" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.12646745" sideWeight="0.8942093" order="0" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
</layout> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
</layout-to-restore>
</component> </component>
<component name="VcsContentAnnotationSettings"> <component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
@ -316,63 +278,26 @@
</option> </option>
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager>
<option name="time" value="1" />
</breakpoint-manager>
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/core/manialinkIdHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="19" column="5" selection-start="306" selection-end="306" vertical-scroll-proportion="-12.423077" vertical-offset="0" max-vertical-offset="748">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/authentication.php">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1853">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ManiaControl.php">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ManiaControl.bat">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ManiaControl.sh"> <entry file="file://$PROJECT_DIR$/ManiaControl.sh">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777" />
<folding />
</state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/plugin.php"> <entry file="file://$PROJECT_DIR$/configs/core.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="21" column="20" selection-start="307" selection-end="307" vertical-scroll-proportion="-11.769231" vertical-offset="51" max-vertical-offset="2380"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/configs/plugins.ManiaControl.xml"> <entry file="file://$PROJECT_DIR$/configs/plugins.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="11" column="0" selection-start="363" selection-end="363" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="323"> <state line="11" column="0" selection-start="363" selection-end="363" vertical-scroll-proportion="0.24066924" vertical-offset="0" max-vertical-offset="777">
<folding>
<marker date="1384000064631" expanded="true" signature="111:311" placeholder="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/configs/core.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -384,16 +309,86 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/core.php"> <entry file="file://$PROJECT_DIR$/core/authentication.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="168" column="13" selection-start="3581" selection-end="3581" vertical-scroll-proportion="-3.9605262" vertical-offset="2555" max-vertical-offset="6613"> <state line="96" column="74" selection-start="2314" selection-end="2321" vertical-scroll-proportion="-6.3157897" vertical-offset="1152" max-vertical-offset="1853">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/manialinkIdHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="19" column="5" selection-start="306" selection-end="306" vertical-scroll-proportion="-12.423077" vertical-offset="0" max-vertical-offset="748">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="68" column="14" selection-start="1719" selection-end="1721" vertical-scroll-proportion="1.4407989" vertical-offset="146" max-vertical-offset="6919">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/commands.php">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="33" selection-start="0" selection-end="21192" vertical-scroll-proportion="0.4122682" vertical-offset="51" max-vertical-offset="11730">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/stats.php">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="268" selection-end="268" vertical-scroll-proportion="0.3566334" vertical-offset="90" max-vertical-offset="5151">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ManiaControl.php">
<provider selected="true" editor-type-id="text-editor">
<state line="26" column="0" selection-start="623" selection-end="623" vertical-scroll-proportion="0.5885486" vertical-offset="0" max-vertical-offset="751">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/server.php">
<provider selected="true" editor-type-id="text-editor">
<state line="241" column="9" selection-start="5767" selection-end="5767" vertical-scroll-proportion="0.5021398" vertical-offset="3745" max-vertical-offset="6579">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="11" column="15" selection-start="146" selection-end="146" vertical-scroll-proportion="-5.230769" vertical-offset="51" max-vertical-offset="2703">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="45" selection-start="452" selection-end="452" vertical-scroll-proportion="-15.5" vertical-offset="124" max-vertical-offset="1547">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/callbacks.php">
<provider selected="true" editor-type-id="text-editor">
<state line="42" column="16" selection-start="0" selection-end="5670" vertical-scroll-proportion="0.24113475" vertical-offset="510" max-vertical-offset="3349">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/pluginHandler.php"> <entry file="file://$PROJECT_DIR$/core/pluginHandler.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="32" column="2" selection-start="484" selection-end="484" vertical-scroll-proportion="0.7243675" vertical-offset="0" max-vertical-offset="751"> <state line="32" column="2" selection-start="478" selection-end="478" vertical-scroll-proportion="0.643026" vertical-offset="0" max-vertical-offset="846">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor">
<state line="117" column="33" selection-start="2501" selection-end="2501" vertical-scroll-proportion="0.6572104" vertical-offset="1433" max-vertical-offset="6647">
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -4,7 +4,7 @@ namespace ManiaControl;
define('ManiaControlDir', __DIR__); define('ManiaControlDir', __DIR__);
require_once __DIR__ . '/core/core.ManiaControl.php'; require_once __DIR__ . '/core/core.php';
// Set process settings // Set process settings
ini_set('memory_limit', '128M'); ini_set('memory_limit', '128M');

View File

@ -17,15 +17,15 @@ class Authentication {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
/** /**
* Construct authentication manager * Construct authentication manager
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('authentication.ManiaControl.xml'); $this->config = Tools::loadConfig('authentication.ManiaControl.xml');
@ -94,8 +94,8 @@ class Authentication {
* @param string $login * @param string $login
*/ */
public function sendNotAllowed($login) { public function sendNotAllowed($login) {
if (!$this->iControl->chat->sendError('You do not have the required rights to perform this command!', $login)) { if (!$this->mc->chat->sendError('You do not have the required rights to perform this command!', $login)) {
trigger_error("Couldn't send forbidden message to login '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send forbidden message to login '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
} }

View File

@ -49,7 +49,7 @@ class Callbacks {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $callbackHandlers = array(); private $callbackHandlers = array();
@ -64,8 +64,8 @@ class Callbacks {
/** /**
* Construct callbacks handler * Construct callbacks handler
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Init values // Init values
$this->last1Second = time(); $this->last1Second = time();
@ -82,7 +82,7 @@ class Callbacks {
$this->triggerCallback(self::CB_IC_ONINIT, array(self::CB_IC_ONINIT)); $this->triggerCallback(self::CB_IC_ONINIT, array(self::CB_IC_ONINIT));
// Simulate begin map // Simulate begin map
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if ($map) { if ($map) {
$this->triggerCallback(self::CB_IC_BEGINMAP, array(self::CB_IC_BEGINMAP, array($map))); $this->triggerCallback(self::CB_IC_BEGINMAP, array(self::CB_IC_BEGINMAP, array($map)));
} }
@ -122,12 +122,12 @@ class Callbacks {
} }
// Get server callbacks // Get server callbacks
if (!$this->iControl->client) return; if (!$this->mc->client) return;
$this->iControl->client->resetError(); $this->mc->client->resetError();
$this->iControl->client->readCB(); $this->mc->client->readCB();
$callbacks = $this->iControl->client->getCBResponses(); $callbacks = $this->mc->client->getCBResponses();
if (!is_array($callbacks) || $this->iControl->client->isError()) { if (!is_array($callbacks) || $this->mc->client->isError()) {
trigger_error("Error reading server callbacks. " . $this->iControl->getClientErrorText()); trigger_error("Error reading server callbacks. " . $this->mc->getClientErrorText());
return; return;
} }

View File

@ -12,7 +12,7 @@ class Chat {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -21,8 +21,8 @@ class Chat {
/** /**
* Construct ManiaControl chat * Construct ManiaControl chat
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('chat.ManiaControl.xml'); $this->config = Tools::loadConfig('chat.ManiaControl.xml');
@ -36,12 +36,12 @@ class Chat {
* @param bool $prefix * @param bool $prefix
*/ */
public function sendChat($message, $login = null, $prefix = false) { public function sendChat($message, $login = null, $prefix = false) {
if (!$this->iControl->client) return false; if (!$this->mc->client) return false;
if ($login === null) { if ($login === null) {
return $this->iControl->client->query('ChatSendServerMessage', ($prefix ? $this->prefix : '') . $message); return $this->mc->client->query('ChatSendServerMessage', ($prefix ? $this->prefix : '') . $message);
} }
else { else {
return $this->iControl->client->query('ChatSendServerMessageToLogin', ($prefix ? $this->prefix : '') . $message, $login); return $this->mc->client->query('ChatSendServerMessageToLogin', ($prefix ? $this->prefix : '') . $message, $login);
} }
} }

View File

@ -12,7 +12,7 @@ class Commands {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -27,16 +27,16 @@ class Commands {
/** /**
* Construct commands handler * Construct commands handler
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('commands.ManiaControl.xml'); $this->config = Tools::loadConfig('commands.ManiaControl.xml');
// Register for callbacks // Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'each5Seconds'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'each5Seconds');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_BILLUPDATED, $this, 'handleBillUpdated'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handleChatCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
// Register basic commands // Register basic commands
$commands = array('help', 'version', 'shutdown', 'shutdownserver', 'networkstats', 'systeminfo', 'getservername', $commands = array('help', 'version', 'shutdown', 'shutdownserver', 'networkstats', 'systeminfo', 'getservername',
@ -102,7 +102,7 @@ class Commands {
{ {
// Payed // Payed
$message = 'Success! Thanks.'; $message = 'Success! Thanks.';
$this->iControl->chat->sendSuccess($message, $login); $this->mc->chat->sendSuccess($message, $login);
unset($this->openBills[$bill[0]]); unset($this->openBills[$bill[0]]);
break; break;
} }
@ -110,14 +110,14 @@ class Commands {
{ {
// Refused // Refused
$message = 'Transaction cancelled.'; $message = 'Transaction cancelled.';
$this->iControl->chat->sendError($message, $login); $this->mc->chat->sendError($message, $login);
unset($this->openBills[$bill[0]]); unset($this->openBills[$bill[0]]);
break; break;
} }
case 6: case 6:
{ {
// Error // Error
$this->iControl->chat->sendError($bill[2], $login); $this->mc->chat->sendError($bill[2], $login);
unset($this->openBills[$bill[0]]); unset($this->openBills[$bill[0]]);
break; break;
} }
@ -134,7 +134,7 @@ class Commands {
private function getRightsLevel($commandName, $defaultLevel) { private function getRightsLevel($commandName, $defaultLevel) {
$command_rights = $this->config->xpath('//' . strtolower($commandName) . '/..'); $command_rights = $this->config->xpath('//' . strtolower($commandName) . '/..');
if (empty($command_rights)) return $defaultLevel; if (empty($command_rights)) return $defaultLevel;
$rights = $this->iControl->authentication->RIGHTS_LEVELS; $rights = $this->mc->authentication->RIGHTS_LEVELS;
$highest_level = null; $highest_level = null;
foreach ($command_rights as $right) { foreach ($command_rights as $right) {
$levelName = $right->getName(); $levelName = $right->getName();
@ -152,13 +152,13 @@ class Commands {
*/ */
private function command_version($chat) { private function command_version($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('version', 'all'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('version', 'all'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->chat->sendInformation('This server is using ManiaControl v' . ManiaControl::VERSION . '!', $login)) { if (!$this->mc->chat->sendInformation('This server is using ManiaControl v' . ManiaControl::VERSION . '!', $login)) {
trigger_error("Couldn't send version to '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send version to '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
@ -167,9 +167,9 @@ class Commands {
*/ */
private function command_help($chat) { private function command_help($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('help', 'all'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('help', 'all'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
// TODO: improve help command // TODO: improve help command
@ -178,7 +178,7 @@ class Commands {
$commands = array_keys($this->commandHandlers); $commands = array_keys($this->commandHandlers);
$count = count($commands); $count = count($commands);
for ($index = 0; $index < $count; $index++) { for ($index = 0; $index < $count; $index++) {
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel($commands[$index], 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel($commands[$index], 'superadmin'))) {
unset($commands[$index]); unset($commands[$index]);
} }
} }
@ -191,8 +191,8 @@ class Commands {
} }
$index++; $index++;
} }
if (!$this->iControl->chat->sendInformation($list, $login)) { if (!$this->mc->chat->sendInformation($list, $login)) {
trigger_error("Couldn't send help list to '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send help list to '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
@ -201,18 +201,18 @@ class Commands {
*/ */
private function command_getplanets($chat) { private function command_getplanets($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('getplanets', 'admin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('getplanets', 'admin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->client->query('GetServerPlanets')) { if (!$this->mc->client->query('GetServerPlanets')) {
trigger_error("Couldn't retrieve server planets. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't retrieve server planets. " . $this->mc->getClientErrorText());
} }
else { else {
$planets = $this->iControl->client->getResponse(); $planets = $this->mc->client->getResponse();
if (!$this->iControl->chat->sendInformation('This Server has ' . $planets . ' Planets!', $login)) { if (!$this->mc->chat->sendInformation('This Server has ' . $planets . ' Planets!', $login)) {
trigger_error("Couldn't send server planets to '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send server planets to '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
} }
@ -222,9 +222,9 @@ class Commands {
*/ */
private function command_donate($chat) { private function command_donate($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('donate', 'all'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('donate', 'all'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$params = explode(' ', $chat[1][2]); $params = explode(' ', $chat[1][2]);
@ -239,22 +239,22 @@ class Commands {
} }
if (count($params) >= 3) { if (count($params) >= 3) {
$receiver = $params[2]; $receiver = $params[2];
$receiverPlayer = $this->iControl->database->getPlayer($receiver); $receiverPlayer = $this->mc->database->getPlayer($receiver);
$receiverName = ($receiverPlayer ? $receiverPlayer['NickName'] : $receiver); $receiverName = ($receiverPlayer ? $receiverPlayer['NickName'] : $receiver);
} }
else { else {
$receiver = ''; $receiver = '';
$receiverName = $this->iControl->server->getName(); $receiverName = $this->mc->server->getName();
} }
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?'; $message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
if (!$this->iControl->client->query('SendBill', $login, $amount, $message, $receiver)) { if (!$this->mc->client->query('SendBill', $login, $amount, $message, $receiver)) {
trigger_error( trigger_error(
"Couldn't create donation of " . $amount . " planets from '" . $login . "' for '" . $receiver . "'. " . "Couldn't create donation of " . $amount . " planets from '" . $login . "' for '" . $receiver . "'. " .
$this->iControl->getClientErrorText()); $this->mc->getClientErrorText());
$this->iControl->chat->sendError("Creating donation failed.", $login); $this->mc->chat->sendError("Creating donation failed.", $login);
} }
else { else {
$bill = $this->iControl->client->getResponse(); $bill = $this->mc->client->getResponse();
$this->openBills[$bill] = $login; $this->openBills[$bill] = $login;
} }
} }
@ -264,9 +264,9 @@ class Commands {
*/ */
private function command_pay($chat) { private function command_pay($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('pay', 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('pay', 'superadmin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$params = explode(' ', $chat[1][2]); $params = explode(' ', $chat[1][2]);
@ -285,15 +285,15 @@ class Commands {
else { else {
$receiver = $login; $receiver = $login;
} }
$message = 'Payout from $<' . $this->iControl->server->getName() . '$>.'; $message = 'Payout from $<' . $this->mc->server->getName() . '$>.';
if (!$this->iControl->client->query('Pay', $receiver, $amount, $message)) { if (!$this->mc->client->query('Pay', $receiver, $amount, $message)) {
trigger_error( trigger_error(
"Couldn't create payout of" . $amount . " planets by '" . $login . "' for '" . $receiver . "'. " . "Couldn't create payout of" . $amount . " planets by '" . $login . "' for '" . $receiver . "'. " .
$this->iControl->getClientErrorText()); $this->mc->getClientErrorText());
$this->iControl->chat->sendError("Creating payout failed.", $login); $this->mc->chat->sendError("Creating payout failed.", $login);
} }
else { else {
$bill = $this->iControl->client->getResponse(); $bill = $this->mc->client->getResponse();
$this->openBills[$bill] = $login; $this->openBills[$bill] = $login;
} }
} }
@ -303,17 +303,17 @@ class Commands {
*/ */
private function command_networkstats($chat) { private function command_networkstats($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('networkstats', 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('networkstats', 'superadmin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$networkStats = $this->iControl->server->getNetworkStats(); $networkStats = $this->mc->server->getNetworkStats();
$message = 'NetworkStats: ' . 'uptime=' . $networkStats['Uptime'] . ', ' . 'nbConn=' . $networkStats['NbrConnection'] . ', ' . $message = 'NetworkStats: ' . 'uptime=' . $networkStats['Uptime'] . ', ' . 'nbConn=' . $networkStats['NbrConnection'] . ', ' .
'recvRate=' . $networkStats['RecvNetRate'] . ', ' . 'sendRate=' . $networkStats['SendNetRate'] . ', ' . 'recvTotal=' . 'recvRate=' . $networkStats['RecvNetRate'] . ', ' . 'sendRate=' . $networkStats['SendNetRate'] . ', ' . 'recvTotal=' .
$networkStats['SendNetRate'] . ', ' . 'sentTotal=' . $networkStats['SendNetRate']; $networkStats['SendNetRate'] . ', ' . 'sentTotal=' . $networkStats['SendNetRate'];
if (!$this->iControl->chat->sendInformation($message, $login)) { if (!$this->mc->chat->sendInformation($message, $login)) {
trigger_error("Couldn't send network stats to '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send network stats to '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
@ -322,16 +322,16 @@ class Commands {
*/ */
private function command_systeminfo($chat) { private function command_systeminfo($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('systeminfo', 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('systeminfo', 'superadmin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$systemInfo = $this->iControl->server->getSystemInfo(); $systemInfo = $this->mc->server->getSystemInfo();
$message = 'SystemInfo: ' . 'ip=' . $systemInfo['PublishedIp'] . ', ' . 'port=' . $systemInfo['Port'] . ', ' . 'p2pPort=' . $message = 'SystemInfo: ' . 'ip=' . $systemInfo['PublishedIp'] . ', ' . 'port=' . $systemInfo['Port'] . ', ' . 'p2pPort=' .
$systemInfo['P2PPort'] . ', ' . 'title=' . $systemInfo['TitleId'] . ', ' . 'login=' . $systemInfo['ServerLogin'] . ', '; $systemInfo['P2PPort'] . ', ' . 'title=' . $systemInfo['TitleId'] . ', ' . 'login=' . $systemInfo['ServerLogin'] . ', ';
if (!$this->iControl->chat->sendInformation($message, $login)) { if (!$this->mc->chat->sendInformation($message, $login)) {
trigger_error("Couldn't send system info to '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send system info to '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
@ -340,12 +340,12 @@ class Commands {
*/ */
private function command_shutdown($chat) { private function command_shutdown($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('shutdown', 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('shutdown', 'superadmin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$this->iControl->quit("ManiaControl shutdown requested by '" . $login . "'"); $this->mc->quit("ManiaControl shutdown requested by '" . $login . "'");
} }
/** /**
@ -353,15 +353,15 @@ class Commands {
*/ */
private function command_startwarmup($chat) { private function command_startwarmup($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('startwarmup', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('startwarmup', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->client->query("SetWarmUp", true)) { if (!$this->mc->client->query("SetWarmUp", true)) {
trigger_error("Couldn't start warmup. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't start warmup. " . $this->mc->getClientErrorText());
$player = $this->iControl->database->getPlayer($login); $player = $this->mc->database->getPlayer($login);
$this->iControl->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> started WarmUp!'); $this->mc->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> started WarmUp!');
} }
} }
@ -370,17 +370,17 @@ class Commands {
*/ */
private function command_stopwarmup($chat) { private function command_stopwarmup($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('stopwarmup', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('stopwarmup', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->client->query("SetWarmUp", false)) { if (!$this->mc->client->query("SetWarmUp", false)) {
trigger_error("Couldn't stop warmup. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't stop warmup. " . $this->mc->getClientErrorText());
} }
else { else {
$player = $this->iControl->database->getPlayer($login); $player = $this->mc->database->getPlayer($login);
$this->iControl->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> stopped WarmUp!'); $this->mc->chat->sendInformation('$<' . ($player ? $player['NickName'] : $login) . '$> stopped WarmUp!');
} }
} }
@ -389,9 +389,9 @@ class Commands {
*/ */
private function command_shutdownserver($chat) { private function command_shutdownserver($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('shutdownserver', 'superadmin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('shutdownserver', 'superadmin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
// Check for delayed shutdown // Check for delayed shutdown
@ -401,10 +401,10 @@ class Commands {
if ($param == 'empty') { if ($param == 'empty') {
$this->serverShutdownEmpty = !$this->serverShutdownEmpty; $this->serverShutdownEmpty = !$this->serverShutdownEmpty;
if ($this->serverShutdownEmpty) { if ($this->serverShutdownEmpty) {
$this->iControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $login); $this->mc->chat->sendInformation("The server will shutdown as soon as it's empty!", $login);
} }
else { else {
$this->iControl->chat->sendInformation("Empty-shutdown cancelled!", $login); $this->mc->chat->sendInformation("Empty-shutdown cancelled!", $login);
} }
} }
else { else {
@ -412,12 +412,12 @@ class Commands {
if ($delay <= 0) { if ($delay <= 0) {
// Cancel shutdown // Cancel shutdown
$this->serverShutdownTime = -1; $this->serverShutdownTime = -1;
$this->iControl->chat->sendInformation("Delayed shutdown cancelled!", $login); $this->mc->chat->sendInformation("Delayed shutdown cancelled!", $login);
} }
else { else {
// Trigger delayed shutdown // Trigger delayed shutdown
$this->serverShutdownTime = time() + $delay * 60.; $this->serverShutdownTime = time() + $delay * 60.;
$this->iControl->chat->sendInformation("The server will shut down in " . $delay . " minutes!", $login); $this->mc->chat->sendInformation("The server will shut down in " . $delay . " minutes!", $login);
} }
} }
} }
@ -431,9 +431,9 @@ class Commands {
*/ */
private function command_kick($chat) { private function command_kick($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$params = explode(' ', $chat[1][2], 3); $params = explode(' ', $chat[1][2], 3);
@ -442,7 +442,7 @@ class Commands {
return; return;
} }
$target = $params[1]; $target = $params[1];
$players = $this->iControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
foreach ($players as $player) { foreach ($players as $player) {
if ($player['Login'] != $target) continue; if ($player['Login'] != $target) continue;
// Kick player // Kick player
@ -452,12 +452,12 @@ class Commands {
else { else {
$message = ""; $message = "";
} }
if (!$this->iControl->client->query('Kick', $target, $message)) { if (!$this->mc->client->query('Kick', $target, $message)) {
trigger_error("Couldn't kick player '" . $target . "'! " . $this->iControl->getClientErrorText()); trigger_error("Couldn't kick player '" . $target . "'! " . $this->mc->getClientErrorText());
} }
return; return;
} }
$this->iControl->chat->sendError("Invalid player login.", $login); $this->mc->chat->sendError("Invalid player login.", $login);
} }
/** /**
@ -465,26 +465,26 @@ class Commands {
*/ */
private function command_removemap($chat) { private function command_removemap($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('kick', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
// TODO: allow params // TODO: allow params
// Get map name // Get map name
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if (!$map) { if (!$map) {
$this->iControl->chat->sendError("Couldn't remove map.", $login); $this->mc->chat->sendError("Couldn't remove map.", $login);
} }
else { else {
$mapName = $map['FileName']; $mapName = $map['FileName'];
// Remove map // Remove map
if (!$this->iControl->client->query('RemoveMap', $mapName)) { if (!$this->mc->client->query('RemoveMap', $mapName)) {
trigger_error("Couldn't remove current map. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't remove current map. " . $this->mc->getClientErrorText());
} }
else { else {
$this->iControl->chat->sendSuccess('Map removed.', $login); $this->mc->chat->sendSuccess('Map removed.', $login);
} }
} }
} }
@ -494,9 +494,9 @@ class Commands {
*/ */
private function command_addmap($chat) { private function command_addmap($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('addmap', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('addmap', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$params = explode(' ', $chat[1][2], 2); $params = explode(' ', $chat[1][2], 2);
@ -505,36 +505,36 @@ class Commands {
return; return;
} }
// Check if ManiaControl can even write to the maps dir // Check if ManiaControl can even write to the maps dir
if (!$this->iControl->client->query('GetMapsDirectory')) { if (!$this->mc->client->query('GetMapsDirectory')) {
trigger_error("Couldn't get map directory. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't get map directory. " . $this->mc->getClientErrorText());
$this->iControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login); $this->mc->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
return; return;
} }
else { else {
$mapDir = $this->iControl->client->getResponse(); $mapDir = $this->mc->client->getResponse();
if (!is_dir($mapDir)) { if (!is_dir($mapDir)) {
trigger_error("ManiaControl doesn't have have access to the maps directory in '" . $mapDir . "'."); trigger_error("ManiaControl doesn't have have access to the maps directory in '" . $mapDir . "'.");
$this->iControl->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login); $this->mc->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login);
return; return;
} }
$dlDir = (string) $this->iControl->config->maps_dir; $dlDir = (string) $this->mc->config->maps_dir;
// Create mx directory if necessary // Create mx directory if necessary
if (!is_dir($mapDir . $dlDir) && !mkdir($mapDir . $dlDir)) { if (!is_dir($mapDir . $dlDir) && !mkdir($mapDir . $dlDir)) {
trigger_error("ManiaControl doesn't have to rights to save maps in'" . $mapDir . $dlDir, "'."); trigger_error("ManiaControl doesn't have to rights to save maps in'" . $mapDir . $dlDir, "'.");
$this->iControl->chat->sendError("ManiaControl doesn't have to rights to save maps.", $login); $this->mc->chat->sendError("ManiaControl doesn't have to rights to save maps.", $login);
return; return;
} }
$mapDir .= $dlDir . '/'; $mapDir .= $dlDir . '/';
// Download the map // Download the map
if (is_numeric($params[1])) { if (is_numeric($params[1])) {
$serverInfo = $this->iControl->server->getSystemInfo(); $serverInfo = $this->mc->server->getSystemInfo();
$title = strtolower(substr($serverInfo['TitleId'], 0, 2)); $title = strtolower(substr($serverInfo['TitleId'], 0, 2));
// Check if map exists // Check if map exists
$url = 'http://' . $title . '.mania-exchange.com/api/tracks/get_track_info/id/' . $params[1] . '?format=json'; $url = 'http://' . $title . '.mania-exchange.com/api/tracks/get_track_info/id/' . $params[1] . '?format=json';
$mapInfo = Tools::loadFile($url); $mapInfo = Tools::loadFile($url);
if (!$mapInfo || strlen($mapInfo) <= 0) { if (!$mapInfo || strlen($mapInfo) <= 0) {
// Invalid id // Invalid id
$this->iControl->chat->sendError('Invalid MX-Id!', $login); $this->mc->chat->sendError('Invalid MX-Id!', $login);
return; return;
} }
$mapInfo = json_decode($mapInfo, true); $mapInfo = json_decode($mapInfo, true);
@ -542,34 +542,34 @@ class Commands {
$file = Tools::loadFile($url); $file = Tools::loadFile($url);
if (!$file) { if (!$file) {
// Download error // Download error
$this->iControl->chat->sendError('Download failed!', $login); $this->mc->chat->sendError('Download failed!', $login);
return; return;
} }
// Save map // Save map
$fileName = $mapDir . $mapInfo['TrackID'] . '_' . $mapInfo['Name'] . '.Map.Gbx'; $fileName = $mapDir . $mapInfo['TrackID'] . '_' . $mapInfo['Name'] . '.Map.Gbx';
if (!file_put_contents($fileName, $file)) { if (!file_put_contents($fileName, $file)) {
// Save error // Save error
$this->iControl->chat->sendError('Saving map failed!', $login); $this->mc->chat->sendError('Saving map failed!', $login);
return; return;
} }
// Check for valid map // Check for valid map
if (!$this->iControl->client->query('CheckMapForCurrentServerParams', $fileName)) { if (!$this->mc->client->query('CheckMapForCurrentServerParams', $fileName)) {
trigger_error("Couldn't check if map is valid. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't check if map is valid. " . $this->mc->getClientErrorText());
} }
else { else {
$response = $this->iControl->client->getResponse(); $response = $this->mc->client->getResponse();
if (!$response) { if (!$response) {
// Inalid map type // Inalid map type
$this->iControl->chat->sendError("Invalid map type.", $login); $this->mc->chat->sendError("Invalid map type.", $login);
return; return;
} }
} }
// Add map to map list // Add map to map list
if (!$this->iControl->client->query('InsertMap', $fileName)) { if (!$this->mc->client->query('InsertMap', $fileName)) {
$this->iControl->chat->sendError("Couldn't add map to match settings!", $login); $this->mc->chat->sendError("Couldn't add map to match settings!", $login);
return; return;
} }
$this->iControl->chat->sendSuccess('Map $<' . $mapInfo['Name'] . '$> successfully added!'); $this->mc->chat->sendSuccess('Map $<' . $mapInfo['Name'] . '$> successfully added!');
} }
else { else {
// TODO: check if map exists locally // TODO: check if map exists locally
@ -583,13 +583,13 @@ class Commands {
*/ */
private function command_nextmap($chat) { private function command_nextmap($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('nextmap', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('nextmap', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->client->query('NextMap')) { if (!$this->mc->client->query('NextMap')) {
trigger_error("Couldn't skip map. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't skip map. " . $this->mc->getClientErrorText());
} }
} }
@ -598,13 +598,13 @@ class Commands {
*/ */
private function command_restartmap($chat) { private function command_restartmap($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('restartmap', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('restartmap', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
if (!$this->iControl->client->query('RestartMap')) { if (!$this->mc->client->query('RestartMap')) {
trigger_error("Couldn't restart map. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't restart map. " . $this->mc->getClientErrorText());
} }
} }
@ -613,13 +613,13 @@ class Commands {
*/ */
private function command_getservername($chat) { private function command_getservername($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('getservername', 'operator'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('getservername', 'operator'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$serverName = $this->iControl->server->getName(); $serverName = $this->mc->server->getName();
$this->iControl->chat->sendInformation("Server Name: " . $serverName, $login); $this->mc->chat->sendInformation("Server Name: " . $serverName, $login);
} }
/** /**
@ -627,9 +627,9 @@ class Commands {
*/ */
private function command_setservername($chat) { private function command_setservername($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
if (!$this->iControl->authentication->checkRight($login, $this->getRightsLevel('setservername', 'admin'))) { if (!$this->mc->authentication->checkRight($login, $this->getRightsLevel('setservername', 'admin'))) {
// Not allowed! // Not allowed!
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
$params = explode(' ', $chat[1][2], 2); $params = explode(' ', $chat[1][2], 2);
@ -638,13 +638,13 @@ class Commands {
return; return;
} }
$serverName = $params[1]; $serverName = $params[1];
if (!$this->iControl->client->query('SetServerName', $serverName)) { if (!$this->mc->client->query('SetServerName', $serverName)) {
trigger_error("Couldn't set server name. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't set server name. " . $this->mc->getClientErrorText());
$this->iControl->chat->sendError("Error!"); $this->mc->chat->sendError("Error!");
} }
else { else {
$serverName = $this->iControl->server->getName(); $serverName = $this->mc->server->getName();
$this->iControl->chat->sendInformation("New Name: " . $serverName); $this->mc->chat->sendInformation("New Name: " . $serverName);
} }
} }
@ -654,7 +654,7 @@ class Commands {
public function each5Seconds() { public function each5Seconds() {
// Empty shutdown // Empty shutdown
if ($this->serverShutdownEmpty) { if ($this->serverShutdownEmpty) {
$players = $this->iControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
if (count($players) <= 0) { if (count($players) <= 0) {
$this->shutdownServer('empty'); $this->shutdownServer('empty');
} }
@ -672,12 +672,12 @@ class Commands {
* Perform server shutdown * Perform server shutdown
*/ */
private function shutdownServer($login = '#') { private function shutdownServer($login = '#') {
$this->iControl->client->resetError(); $this->mc->client->resetError();
if (!$this->iControl->client->query('StopServer') || $this->iControl->client->isError()) { if (!$this->mc->client->query('StopServer') || $this->mc->client->isError()) {
trigger_error("Server shutdown command from '" . $login . "' failed. " . $this->iControl->getClientErrorText()); trigger_error("Server shutdown command from '" . $login . "' failed. " . $this->mc->getClientErrorText());
return; return;
} }
$this->iControl->quit("Server shutdown requested by '" . $login . "'"); $this->mc->quit("Server shutdown requested by '" . $login . "'");
} }
} }

View File

@ -13,6 +13,8 @@ require_once __DIR__ . '/database.php';
require_once __DIR__ . '/server.php'; require_once __DIR__ . '/server.php';
require_once __DIR__ . '/stats.php'; require_once __DIR__ . '/stats.php';
require_once __DIR__ . '/tools.php'; require_once __DIR__ . '/tools.php';
require_once __DIR__ . '/pluginHandler.php';
require_once __DIR__ . '/manialinkIdHandler.php';
list($endiantest) = array_values(unpack('L1L', pack('V', 1))); list($endiantest) = array_values(unpack('L1L', pack('V', 1)));
if ($endiantest == 1) { if ($endiantest == 1) {
require_once __DIR__ . '/PhpRemote/GbxRemote.inc.php'; require_once __DIR__ . '/PhpRemote/GbxRemote.inc.php';
@ -164,7 +166,7 @@ class ManiaControl {
// Load plugins // Load plugins
//$this->loadPlugins(); //$this->loadPlugins();
$this->pluginhandler->loadPlugins(); $this->pluginHandler->loadPlugins();
// Connect to server // Connect to server
$this->connect(); $this->connect();
@ -191,12 +193,12 @@ class ManiaControl {
$this->callbacks->handleCallbacks(); $this->callbacks->handleCallbacks();
// Loop plugins // Loop plugins
foreach ($this->plugins as $plugin) { /*foreach ($this->plugins as $plugin) {
if (!method_exists($plugin, 'loop')) { if (!method_exists($plugin, 'loop')) {
continue; continue;
} }
$plugin->loop(); $plugin->loop();
} }*/
// Yield for next tick // Yield for next tick
$loopEnd = microtime(true); $loopEnd = microtime(true);

View File

@ -22,7 +22,7 @@ class Database {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -31,12 +31,12 @@ class Database {
/** /**
* Construct database connection * Construct database connection
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('database.ManiaControl.xml'); $this->config = Tools::loadConfig('database.ManiaControl.xml');
$this->mControl->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml'); $this->mc->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
// Get mysql server information // Get mysql server information
$host = $this->config->xpath('host'); $host = $this->config->xpath('host');
@ -73,8 +73,8 @@ class Database {
$this->initTables(); $this->initTables();
// Register for callbacks // Register for callbacks
$this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second');
$this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap');
} }
/** /**
@ -227,7 +227,7 @@ class Database {
*/ */
public function handle5Second($callback = null) { public function handle5Second($callback = null) {
// Save current players in database // Save current players in database
$players = $this->mControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
if ($players) { if ($players) {
$query = ""; $query = "";
foreach ($players as $player) { foreach ($players as $player) {

View File

@ -19,13 +19,15 @@ namespace ManiaControl;
private $author; private $author;
private $updateUrl; private $updateUrl;
private $name; private $name;
private $description;
private $active; private $active;
public function __construct($mc, $name, $version = 0, $author = '', $updateUrl = ''){ public function __construct($mc, $name, $version = 0, $author = '', $description = '', $updateUrl = ''){
$this->mc = $mc; $this->mc = $mc;
$this->name = $name; $this->name = $name;
$this->version = $version; $this->version = $version;
$this->author = $author; $this->author = $author;
$this->description = $description;
$this->updateUrl = $updateUrl; $this->updateUrl = $updateUrl;
$this->mc->pluginHandler->registerPlugin($this); $this->mc->pluginHandler->registerPlugin($this);
@ -131,5 +133,22 @@ namespace ManiaControl;
{ {
return $this->name; return $this->name;
} }
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
} }
?> ?>

View File

@ -18,7 +18,7 @@ namespace ManiaControl;
private $plugins; private $plugins;
public function __construct($mc){ public function __construct($mc){
$this->mControl = $mc; $this->mc = $mc;
$this->plugins = array(); $this->plugins = array();
} }

View File

@ -22,20 +22,20 @@ class Server {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
/** /**
* Construct server * Construct server
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('server.ManiaControl.xml'); $this->config = Tools::loadConfig('server.ManiaControl.xml');
$this->iControl->checkConfig($this->config, array('host', 'port', 'login', 'pass'), 'server'); $this->mc->checkConfig($this->config, array('host', 'port', 'login', 'pass'), 'server');
// Register for callbacks // Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'eachSecond'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'eachSecond');
} }
/** /**
@ -52,11 +52,11 @@ class Server {
* @return string * @return string
*/ */
public function getDataDirectory() { public function getDataDirectory() {
if (!$this->iControl->client->query('GameDataDirectory')) { if (!$this->mc->client->query('GameDataDirectory')) {
trigger_error("Couldn't get data directory. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't get data directory. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
@ -87,54 +87,54 @@ class Server {
public function getInfo($detailed = false) { public function getInfo($detailed = false) {
if ($detailed) { if ($detailed) {
$login = $this->getLogin(); $login = $this->getLogin();
if (!$this->iControl->client->query('GetDetailedPlayerInfo', $login)) { if (!$this->mc->client->query('GetDetailedPlayerInfo', $login)) {
trigger_error("Couldn't fetch detailed server player info. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch detailed server player info. " . $this->mc->getClientErrorText());
return null; return null;
} }
} }
else { else {
if (!$this->iControl->client->query('GetMainServerPlayerInfo')) { if (!$this->mc->client->query('GetMainServerPlayerInfo')) {
trigger_error("Couldn't fetch server player info. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch server player info. " . $this->mc->getClientErrorText());
return null; return null;
} }
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
* Get server options * Get server options
*/ */
public function getOptions() { public function getOptions() {
if (!$this->iControl->client->query('GetServerOptions')) { if (!$this->mc->client->query('GetServerOptions')) {
trigger_error("Couldn't fetch server options. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch server options. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
* Fetch server name * Fetch server name
*/ */
public function getName() { public function getName() {
if (!$this->iControl->client->query('GetServerName')) { if (!$this->mc->client->query('GetServerName')) {
trigger_error("Couldn't fetch server name. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch server name. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
* Fetch server version * Fetch server version
*/ */
public function getVersion($forceRefresh = false) { public function getVersion($forceRefresh = false) {
if (isset($this->iControl->client->version) && !$forceRefresh) return $this->iControl->client->version; if (isset($this->mc->client->version) && !$forceRefresh) return $this->mc->client->version;
if (!$this->iControl->client->query('GetVersion')) { if (!$this->mc->client->query('GetVersion')) {
trigger_error("Couldn't fetch server version. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch server version. " . $this->mc->getClientErrorText());
return null; return null;
} }
else { else {
$this->iControl->client->version = $this->iControl->client->getResponse(); $this->mc->client->version = $this->mc->client->getResponse();
return $this->iControl->client->version; return $this->mc->client->version;
} }
} }
@ -142,11 +142,11 @@ class Server {
* Fetch server system info * Fetch server system info
*/ */
public function getSystemInfo($forceRefresh = false, &$client = null) { public function getSystemInfo($forceRefresh = false, &$client = null) {
if (!$this->iControl->client && !$client) return null; if (!$this->mc->client && !$client) return null;
if (!$client) $client = $this->iControl->client; if (!$client) $client = $this->mc->client;
if (isset($client->systemInfo) && !$forceRefresh) return $client->systemInfo; if (isset($client->systemInfo) && !$forceRefresh) return $client->systemInfo;
if (!$client->query('GetSystemInfo')) { if (!$client->query('GetSystemInfo')) {
trigger_error("Couldn't fetch server system info. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't fetch server system info. " . $this->mc->getClientErrorText($client));
return null; return null;
} }
else { else {
@ -159,14 +159,14 @@ class Server {
* Fetch network status * Fetch network status
*/ */
public function getNetworkStats($forceRefresh = false) { public function getNetworkStats($forceRefresh = false) {
if (isset($this->iControl->client->networkStats) && !$forceRefresh) return $this->iControl->client->networkStats; if (isset($this->mc->client->networkStats) && !$forceRefresh) return $this->mc->client->networkStats;
if (!$this->iControl->client->query('GetNetworkStats')) { if (!$this->mc->client->query('GetNetworkStats')) {
trigger_error("Couldn't fetch network stats. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch network stats. " . $this->mc->getClientErrorText());
return null; return null;
} }
else { else {
$this->iControl->client->networkStats = $this->iControl->client->getResponse(); $this->mc->client->networkStats = $this->mc->client->getResponse();
return $this->iControl->client->networkStats; return $this->mc->client->networkStats;
} }
} }
@ -182,11 +182,11 @@ class Server {
$gameMode = $parseValue; $gameMode = $parseValue;
} }
else { else {
if (!$this->iControl->client->query('GetGameMode')) { if (!$this->mc->client->query('GetGameMode')) {
trigger_error("Couldn't fetch current game mode. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch current game mode. " . $this->mc->getClientErrorText());
return null; return null;
} }
$gameMode = $this->iControl->client->getResponse(); $gameMode = $this->mc->client->getResponse();
} }
if ($stringValue) { if ($stringValue) {
switch ($gameMode) { switch ($gameMode) {
@ -236,19 +236,19 @@ class Server {
public function getPlayer($login, $detailed = false) { public function getPlayer($login, $detailed = false) {
if (!$login) return null; if (!$login) return null;
$command = ($detailed ? 'GetDetailedPlayerInfo' : 'GetPlayerInfo'); $command = ($detailed ? 'GetDetailedPlayerInfo' : 'GetPlayerInfo');
if (!$this->iControl->client->query($command, $login)) { if (!$this->mc->client->query($command, $login)) {
trigger_error("Couldn't player info for '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't player info for '" . $login . "'. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
* Fetch all players * Fetch all players
*/ */
public function getPlayers(&$client = null, &$purePlayers = null, &$pureSpectators = null) { public function getPlayers(&$client = null, &$purePlayers = null, &$pureSpectators = null) {
if (!$this->iControl->client && !$client) return null; if (!$this->mc->client && !$client) return null;
if (!$client) $client = $this->iControl->client; if (!$client) $client = $this->mc->client;
$fetchLength = 30; $fetchLength = 30;
$offset = 0; $offset = 0;
$players = array(); $players = array();
@ -257,7 +257,7 @@ class Server {
$tries = 0; $tries = 0;
while ($tries < 10) { while ($tries < 10) {
if (!$client->query('GetPlayerList', $fetchLength, $offset)) { if (!$client->query('GetPlayerList', $fetchLength, $offset)) {
trigger_error("Couldn't get player list. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't get player list. " . $this->mc->getClientErrorText($client));
$tries++; $tries++;
} }
else { else {
@ -297,11 +297,11 @@ class Server {
*/ */
public function getValidationReplay($login) { public function getValidationReplay($login) {
if (!$login) return null; if (!$login) return null;
if (!$this->iControl->client->query('GetValidationReplay', $login)) { if (!$this->mc->client->query('GetValidationReplay', $login)) {
trigger_error("Couldn't get validation replay of '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't get validation replay of '" . $login . "'. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
public function getGhostReplay($login) { public function getGhostReplay($login) {
@ -317,8 +317,8 @@ class Server {
$fileName = 'Ghost.' . $login . '.' . $gameMode . '.' . $time . '.' . $map['UId'] . '.Replay.Gbx'; $fileName = 'Ghost.' . $login . '.' . $gameMode . '.' . $time . '.' . $map['UId'] . '.Replay.Gbx';
// Save ghost replay // Save ghost replay
if (!$this->iControl->client->query('SaveBestGhostsReplay', $login, self::GHOSTREPLAYDIR . $fileName)) { if (!$this->mc->client->query('SaveBestGhostsReplay', $login, self::GHOSTREPLAYDIR . $fileName)) {
trigger_error("Couldn't save ghost replay. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't save ghost replay. " . $this->mc->getClientErrorText());
return null; return null;
} }
@ -335,12 +335,12 @@ class Server {
* Fetch current map * Fetch current map
*/ */
public function getMap() { public function getMap() {
if (!$this->iControl->client) return null; if (!$this->mc->client) return null;
if (!$this->iControl->client->query('GetCurrentMapInfo')) { if (!$this->mc->client->query('GetCurrentMapInfo')) {
trigger_error("Couldn't fetch map info. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't fetch map info. " . $this->mc->getClientErrorText());
return null; return null;
} }
return $this->iControl->client->getResponse(); return $this->mc->client->getResponse();
} }
/** /**
@ -353,7 +353,7 @@ class Server {
if ($response['Code'] === 4) return true; if ($response['Code'] === 4) return true;
// Server not yet in given status -> Wait for it... // Server not yet in given status -> Wait for it...
$waitBegin = time(); $waitBegin = time();
$timeoutTags = $this->iControl->config->xpath('timeout'); $timeoutTags = $this->mc->config->xpath('timeout');
$maxWaitTime = (!empty($timeoutTags) ? (int) $timeoutTags[0] : 20); $maxWaitTime = (!empty($timeoutTags) ? (int) $timeoutTags[0] : 20);
$lastStatus = $response['Name']; $lastStatus = $response['Name'];
error_log("Waiting for server to reach status " . $statusCode . "..."); error_log("Waiting for server to reach status " . $statusCode . "...");
@ -370,7 +370,7 @@ class Server {
// It took too long to reach the status // It took too long to reach the status
trigger_error( trigger_error(
"Server couldn't reach status " . $statusCode . " after " . $maxWaitTime . " seconds! " . "Server couldn't reach status " . $statusCode . " after " . $maxWaitTime . " seconds! " .
$this->iControl->getClientErrorText()); $this->mc->getClientErrorText());
return false; return false;
} }
} }

View File

@ -17,15 +17,15 @@ class Stats {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
/** /**
* Constuct stats manager * Constuct stats manager
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('stats.ManiaControl.xml'); $this->config = Tools::loadConfig('stats.ManiaControl.xml');
@ -35,11 +35,11 @@ class Stats {
$this->initTables(); $this->initTables();
// Register for needed callbacks // Register for needed callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_ENDMAP, $this, 'handleEndMap'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_ENDMAP, $this, 'handleEndMap');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
} }
/** /**
@ -78,7 +78,7 @@ class Stats {
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tracks player stats' AUTO_INCREMENT=1;"; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tracks player stats' AUTO_INCREMENT=1;";
// Perform queries // Perform queries
if (!$this->iControl->database->multiQuery($query)) { if (!$this->mc->database->multiQuery($query)) {
trigger_error("Creating stats tables failed."); trigger_error("Creating stats tables failed.");
} }
} }
@ -120,7 +120,7 @@ class Stats {
} }
// Perform query // Perform query
if (!$this->iControl->database->multiQuery($multiquery)) { if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on end map failed."); trigger_error("Perform queries on end map failed.");
} }
} }
@ -139,7 +139,7 @@ class Stats {
`Login`, `Login`,
`chatCount` `chatCount`
) VALUES ( ) VALUES (
'" . $this->iControl->database->escape($login) . "', '" . $this->mc->database->escape($login) . "',
1 1
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
`chatCount` = `chatCount` + VALUES(`chatCount`) `chatCount` = `chatCount` + VALUES(`chatCount`)
@ -147,7 +147,7 @@ class Stats {
} }
// Perform query // Perform query
if (!$this->iControl->database->multiQuery($multiquery)) { if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player chat failed."); trigger_error("Perform queries on player chat failed.");
} }
} }
@ -174,7 +174,7 @@ class Stats {
// Track server max players // Track server max players
if ($this->settings->track_server_max_players) { if ($this->settings->track_server_max_players) {
$players = $this->iControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
$multiquery .= "INSERT INTO `" . self::TABLE_STATS_SERVER . "` ( $multiquery .= "INSERT INTO `" . self::TABLE_STATS_SERVER . "` (
`day`, `day`,
`maxPlayerCount` `maxPlayerCount`
@ -193,7 +193,7 @@ class Stats {
`lastJoin`, `lastJoin`,
`connectCount` `connectCount`
) VALUES ( ) VALUES (
'" . $this->iControl->database->escape($login) . "', '" . $this->mc->database->escape($login) . "',
NOW(), NOW(),
1 1
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
@ -203,7 +203,7 @@ class Stats {
} }
// Perform query // Perform query
if (!$this->iControl->database->multiQuery($multiquery)) { if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player connect failed."); trigger_error("Perform queries on player connect failed.");
} }
} }
@ -218,9 +218,9 @@ class Stats {
// Track player playtime // Track player playtime
if ($this->settings->track_player_playtime) { if ($this->settings->track_player_playtime) {
$query = "SELECT `lastJoin` FROM `" . self::TABLE_STATS_PLAYERS . "` $query = "SELECT `lastJoin` FROM `" . self::TABLE_STATS_PLAYERS . "`
WHERE `Login` = '" . $this->iControl->database->escape($login) . "' WHERE `Login` = '" . $this->mc->database->escape($login) . "'
;"; ;";
$result = $this->iControl->database->query($query); $result = $this->mc->database->query($query);
if (!$result) { if (!$result) {
// Error // Error
trigger_error("Error selecting player join time from '" . $login . "'."); trigger_error("Error selecting player join time from '" . $login . "'.");
@ -230,12 +230,12 @@ class Stats {
while ($row = $result->fetch_object()) { while ($row = $result->fetch_object()) {
if (!property_exists($row, 'lastJoin')) continue; if (!property_exists($row, 'lastJoin')) continue;
$lastJoin = strtotime($row->lastJoin); $lastJoin = strtotime($row->lastJoin);
$lastJoin = ($lastJoin > $this->iControl->startTime ? $lastJoin : $this->iControl->startTime); $lastJoin = ($lastJoin > $this->mc->startTime ? $lastJoin : $this->mc->startTime);
$multiquery .= "INSERT INTO `" . self::TABLE_STATS_PLAYERS . "` ( $multiquery .= "INSERT INTO `" . self::TABLE_STATS_PLAYERS . "` (
`Login`, `Login`,
`playTime` `playTime`
) VALUES ( ) VALUES (
'" . $this->iControl->database->escape($login) . "', '" . $this->mc->database->escape($login) . "',
TIMESTAMPDIFF(SECOND, '" . Tools::timeToTimestamp($lastJoin) . "', NOW()) TIMESTAMPDIFF(SECOND, '" . Tools::timeToTimestamp($lastJoin) . "', NOW())
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
`playTime` = `playTime` + VALUES(`playTime`) `playTime` = `playTime` + VALUES(`playTime`)
@ -246,7 +246,7 @@ class Stats {
} }
// Perform query // Perform query
if (!$this->iControl->database->multiQuery($multiquery)) { if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player connect failed."); trigger_error("Perform queries on player connect failed.");
} }
} }
@ -280,7 +280,7 @@ class Stats {
`Login`, `Login`,
`finishCount` `finishCount`
) VALUES ( ) VALUES (
'" . $this->iControl->database->escape($login) . "', '" . $this->mc->database->escape($login) . "',
1 1
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
`finishCount` = `finishCount` + VALUES(`finishCount`) `finishCount` = `finishCount` + VALUES(`finishCount`)
@ -288,7 +288,7 @@ class Stats {
} }
// Perform query // Perform query
if (!$this->iControl->database->multiQuery($multiquery)) { if (!$this->mc->database->multiQuery($multiquery)) {
trigger_error("Perform queries on player finish failed."); trigger_error("Perform queries on player finish failed.");
} }
} }

View File

@ -16,7 +16,7 @@ class Plugin_Chatlog extends Plugin{
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -25,8 +25,8 @@ class Plugin_Chatlog extends Plugin{
/** /**
* Constuct chatlog plugin * Constuct chatlog plugin
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('chatlog.plugin.xml'); $this->config = Tools::loadConfig('chatlog.plugin.xml');
@ -38,7 +38,7 @@ class Plugin_Chatlog extends Plugin{
$this->loadSettings(); $this->loadSettings();
// Register for callbacksc // Register for callbacksc
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
error_log('Chatlog Pugin v' . self::VERSION . ' ready!'); error_log('Chatlog Pugin v' . self::VERSION . ' ready!');
} }

View File

@ -18,7 +18,7 @@ class Plugin_Karma {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -27,10 +27,10 @@ class Plugin_Karma {
/** /**
* Construct plugin * Construct plugin
* *
* @param object $mControl * @param object $mc
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('karma.plugin.xml'); $this->config = Tools::loadConfig('karma.plugin.xml');
@ -40,10 +40,10 @@ class Plugin_Karma {
$this->initDatabase(); $this->initDatabase();
// Register for callbacks // Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswerCallback'); 'handleManialinkPageAnswerCallback');
error_log('Karma Pugin v' . self::VERSION . ' ready!'); error_log('Karma Pugin v' . self::VERSION . ' ready!');
@ -57,7 +57,7 @@ class Plugin_Karma {
$this->sendManialinkRequested = -1; $this->sendManialinkRequested = -1;
// Send manialink to all players // Send manialink to all players
$players = $this->iControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
foreach ($players as $player) { foreach ($players as $player) {
$login = $player['Login']; $login = $player['Login'];
$manialink = $this->buildManialink($login); $manialink = $this->buildManialink($login);
@ -66,7 +66,7 @@ class Plugin_Karma {
$this->sendManialinkRequested = time() + 5; $this->sendManialinkRequested = time() + 5;
continue; continue;
} }
Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login); Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
} }
} }
} }
@ -100,7 +100,7 @@ class Plugin_Karma {
$login = $callback[1][0]; $login = $callback[1][0];
$manialink = $this->buildManialink($login); $manialink = $this->buildManialink($login);
if (!$manialink) return; if (!$manialink) return;
Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login); Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
} }
/** /**
@ -116,9 +116,9 @@ class Plugin_Karma {
PRIMARY KEY (`index`), PRIMARY KEY (`index`),
UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`) UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;"; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;";
$result = $this->iControl->database->query($query); $result = $this->mc->database->query($query);
if ($this->iControl->database->mysqli->error) { if ($this->mc->database->mysqli->error) {
trigger_error('MySQL Error on creating karma table. ' . $this->iControl->database->mysqli->error, E_USER_ERROR); trigger_error('MySQL Error on creating karma table. ' . $this->mc->database->mysqli->error, E_USER_ERROR);
} }
} }
@ -158,9 +158,9 @@ class Plugin_Karma {
// Save vote // Save vote
$login = $callback[1][1]; $login = $callback[1][1];
$playerIndex = $this->iControl->database->getPlayerIndex($login); $playerIndex = $this->mc->database->getPlayerIndex($login);
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
$mapIndex = $this->iControl->database->getMapIndex($map['UId']); $mapIndex = $this->mc->database->getMapIndex($map['UId']);
$query = "INSERT INTO `" . self::TABLE_KARMA . "` ( $query = "INSERT INTO `" . self::TABLE_KARMA . "` (
`mapIndex`, `mapIndex`,
`playerIndex`, `playerIndex`,
@ -171,11 +171,11 @@ class Plugin_Karma {
" . $vote . " " . $vote . "
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
`vote` = VALUES(`vote`);"; `vote` = VALUES(`vote`);";
$result = $this->iControl->database->query($query); $result = $this->mc->database->query($query);
if (!$result) return; if (!$result) return;
// Send success message // Send success message
$this->iControl->chat->sendSuccess('Vote successfully updated!', $login); $this->mc->chat->sendSuccess('Vote successfully updated!', $login);
// Send updated manialink // Send updated manialink
$this->sendManialinkRequested = time() + 1; $this->sendManialinkRequested = time() + 1;
@ -190,14 +190,14 @@ class Plugin_Karma {
$pos_x = (float) $this->config->pos_x; $pos_x = (float) $this->config->pos_x;
$pos_y = (float) $this->config->pos_y; $pos_y = (float) $this->config->pos_y;
$mysqli = $this->iControl->database->mysqli; $mysqli = $this->mc->database->mysqli;
// Get indezes // Get indezes
$playerIndex = $this->iControl->database->getPlayerIndex($login); $playerIndex = $this->mc->database->getPlayerIndex($login);
if ($playerIndex === null) return null; if ($playerIndex === null) return null;
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if (!$map) return null; if (!$map) return null;
$mapIndex = $this->iControl->database->getMapIndex($map['UId']); $mapIndex = $this->mc->database->getMapIndex($map['UId']);
if ($mapIndex === null) return null; if ($mapIndex === null) return null;
// Get votings // Get votings

View File

@ -17,15 +17,15 @@ class Plugin_Obstacle extends Plugin {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
/** /**
* Constuct obstacle plugin * Constuct obstacle plugin
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('obstacle.plugin.xml'); $this->config = Tools::loadConfig('obstacle.plugin.xml');
@ -34,7 +34,7 @@ class Plugin_Obstacle extends Plugin {
if (!Tools::toBool($this->config->enabled)) return; if (!Tools::toBool($this->config->enabled)) return;
// Register for jump command // Register for jump command
$this->iControl->commands->registerCommandHandler('jumpto', $this, 'command_jumpto'); $this->mc->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
error_log('Obstacle Pugin v' . self::VERSION . ' ready!'); error_log('Obstacle Pugin v' . self::VERSION . ' ready!');
} }
@ -45,16 +45,16 @@ class Plugin_Obstacle extends Plugin {
public function command_jumpto($chat) { public function command_jumpto($chat) {
$login = $chat[1][1]; $login = $chat[1][1];
$rightLevel = (string) $this->config->jumps_rightlevel; $rightLevel = (string) $this->config->jumps_rightlevel;
if (!$this->iControl->authentication->checkRight($login, $rightLevel)) { if (!$this->mc->authentication->checkRight($login, $rightLevel)) {
// Not allowed // Not allowed
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
} }
else { else {
// Send jump callback // Send jump callback
$params = explode(' ', $chat[1][2], 2); $params = explode(' ', $chat[1][2], 2);
$param = $login . ";" . $params[1] . ";"; $param = $login . ";" . $params[1] . ";";
if (!$this->iControl->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) { if (!$this->mc->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
} }

View File

@ -14,15 +14,15 @@ abstract class Plugin_Name {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
/** /**
* Construct plugin * Construct plugin
* *
* @param object $mControl * @param object $mc
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
error_log('Pugin v' . self::VERSION . ' ready!'); error_log('Pugin v' . self::VERSION . ' ready!');
} }

View File

@ -37,7 +37,7 @@ class Plugin_Records {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $settings = null; private $settings = null;
@ -58,8 +58,8 @@ class Plugin_Records {
/** /**
* Constuct plugin * Constuct plugin
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('records.plugin.xml'); $this->config = Tools::loadConfig('records.plugin.xml');
@ -74,17 +74,17 @@ class Plugin_Records {
$this->initTables(); $this->initTables();
// Register for callbacks // Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint');
error_log('Records Pugin v' . self::VERSION . ' ready!'); error_log('Records Pugin v' . self::VERSION . ' ready!');
} }
@ -93,7 +93,7 @@ class Plugin_Records {
* Init needed database tables * Init needed database tables
*/ */
private function initTables() { private function initTables() {
$database = $this->iControl->database; $database = $this->mc->database;
// Records table // Records table
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` ( $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` (
@ -227,7 +227,7 @@ class Plugin_Records {
if ($init || !array_key_exists('serverData', $this->dedimaniaData) || !is_array($this->dedimaniaData['serverData'])) { if ($init || !array_key_exists('serverData', $this->dedimaniaData) || !is_array($this->dedimaniaData['serverData'])) {
$serverData = array(); $serverData = array();
$serverData['Game'] = 'TM2'; $serverData['Game'] = 'TM2';
$serverInfo = $this->iControl->server->getInfo(true); $serverInfo = $this->mc->server->getInfo(true);
// Get dedimania account data // Get dedimania account data
$accounts = $this->config->xpath('dedimania_records/account'); $accounts = $this->config->xpath('dedimania_records/account');
@ -250,9 +250,9 @@ class Plugin_Records {
// Complete seesion data // Complete seesion data
$serverData['Path'] = $serverInfo['Path']; $serverData['Path'] = $serverInfo['Path'];
$systemInfo = $this->iControl->server->getSystemInfo(); $systemInfo = $this->mc->server->getSystemInfo();
$serverData['Packmask'] = substr($systemInfo['TitleId'], 2); $serverData['Packmask'] = substr($systemInfo['TitleId'], 2);
$serverVersion = $this->iControl->server->getVersion(); $serverVersion = $this->mc->server->getVersion();
$serverData['ServerVersion'] = $serverVersion['Version']; $serverData['ServerVersion'] = $serverVersion['Version'];
$serverData['ServerBuild'] = $serverVersion['Build']; $serverData['ServerBuild'] = $serverVersion['Build'];
$serverData['Tool'] = 'ManiaControl'; $serverData['Tool'] = 'ManiaControl';
@ -352,7 +352,7 @@ class Plugin_Records {
if ($this->settings->local_records_enabled) $this->sendManialink($this->manialinks[self::MLID_LOCAL], $login); if ($this->settings->local_records_enabled) $this->sendManialink($this->manialinks[self::MLID_LOCAL], $login);
if ($this->settings->dedimania_enabled && $this->dedimaniaData['context']) { if ($this->settings->dedimania_enabled && $this->dedimaniaData['context']) {
$player = $this->iControl->server->getPlayer($login, true); $player = $this->mc->server->getPlayer($login, true);
if ($player) { if ($player) {
// Send dedimania request // Send dedimania request
$data = array($this->dedimaniaData['sessionId'], $player['Login'], $player['NickName'], $player['Path'], $data = array($this->dedimaniaData['sessionId'], $player['Login'], $player['NickName'], $player['Path'],
@ -435,7 +435,7 @@ class Plugin_Records {
* Build map info struct for dedimania requests * Build map info struct for dedimania requests
*/ */
private function getMapInfo() { private function getMapInfo() {
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if (!$map) return null; if (!$map) return null;
$mapInfo = array(); $mapInfo = array();
$mapInfo['UId'] = $map['UId']; $mapInfo['UId'] = $map['UId'];
@ -528,12 +528,12 @@ class Plugin_Records {
* Build server info struct for callbacks * Build server info struct for callbacks
*/ */
private function getSrvInfo() { private function getSrvInfo() {
$server = $this->iControl->server->getOptions(); $server = $this->mc->server->getOptions();
if (!$server) return null; if (!$server) return null;
$client = null; $client = null;
$players = null; $players = null;
$spectators = null; $spectators = null;
$this->iControl->server->getPlayers($client, $players, $spectators); $this->mc->server->getPlayers($client, $players, $spectators);
if (!is_array($players) || !is_array($spectators)) return null; if (!is_array($players) || !is_array($spectators)) return null;
return array('SrvName' => $server['Name'], 'Comment' => $server['Comment'], 'Private' => (strlen($server['Password']) > 0), return array('SrvName' => $server['Name'], 'Comment' => $server['Comment'], 'Private' => (strlen($server['Password']) > 0),
'NumPlayers' => count($players), 'MaxPlayers' => $server['CurrentMaxPlayers'], 'NumSpecs' => count($spectators), 'NumPlayers' => count($players), 'MaxPlayers' => $server['CurrentMaxPlayers'], 'NumSpecs' => count($spectators),
@ -547,7 +547,7 @@ class Plugin_Records {
$client = null; $client = null;
$players; $players;
$spectators; $spectators;
$allPlayers = $this->iControl->server->getPlayers($client, $players, $spectators); $allPlayers = $this->mc->server->getPlayers($client, $players, $spectators);
if (!is_array($players) || !is_array($spectators)) return null; if (!is_array($players) || !is_array($spectators)) return null;
$playerInfo = array(); $playerInfo = array();
foreach ($allPlayers as $player) { foreach ($allPlayers as $player) {
@ -560,9 +560,9 @@ class Plugin_Records {
* Get dedi string representation of the current game mode * Get dedi string representation of the current game mode
*/ */
private function getGameModeString() { private function getGameModeString() {
$gameMode = $this->iControl->server->getGameMode(); $gameMode = $this->mc->server->getGameMode();
if ($gameMode === null) { if ($gameMode === null) {
trigger_error("Couldn't retrieve game mode. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't retrieve game mode. " . $this->mc->getClientErrorText());
return null; return null;
} }
switch ($gameMode) { switch ($gameMode) {
@ -585,7 +585,7 @@ class Plugin_Records {
* Build votes info struct for callbacks * Build votes info struct for callbacks
*/ */
private function getVotesInfo() { private function getVotesInfo() {
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if (!$map) return null; if (!$map) return null;
$gameMode = $this->getGameModeString(); $gameMode = $this->getGameModeString();
if (!$gameMode) return null; if (!$gameMode) return null;
@ -646,14 +646,14 @@ class Plugin_Records {
$login = $data[1]; $login = $data[1];
$time = $data[2]; $time = $data[2];
$newMap = $this->iControl->server->getMap(); $newMap = $this->mc->server->getMap();
if (!$newMap) return; if (!$newMap) return;
if (!$this->mapInfo || $this->mapInfo['UId'] !== $newMap['UId']) { if (!$this->mapInfo || $this->mapInfo['UId'] !== $newMap['UId']) {
$this->mapInfo = $this->getMapInfo(); $this->mapInfo = $this->getMapInfo();
} }
$map = $newMap; $map = $newMap;
$player = $this->iControl->server->getPlayer($login); $player = $this->mc->server->getPlayer($login);
if ($this->settings->local_records_enabled) { if ($this->settings->local_records_enabled) {
// Get old record of the player // Get old record of the player
@ -668,13 +668,13 @@ class Plugin_Records {
// Same time // Same time
$message = '$<' . $player['NickName'] . '$> equalized her/his $<$o' . $oldRecord['rank'] . '.$> Local Record: ' . $message = '$<' . $player['NickName'] . '$> equalized her/his $<$o' . $oldRecord['rank'] . '.$> Local Record: ' .
Tools::formatTime($oldRecord['time']); Tools::formatTime($oldRecord['time']);
$this->iControl->chat->sendInformation($message); $this->mc->chat->sendInformation($message);
$save = false; $save = false;
} }
} }
if ($save) { if ($save) {
// Save time // Save time
$database = $this->iControl->database; $database = $this->mc->database;
$query = "INSERT INTO `" . self::TABLE_RECORDS . "` ( $query = "INSERT INTO `" . self::TABLE_RECORDS . "` (
`mapUId`, `mapUId`,
`Login`, `Login`,
@ -701,7 +701,7 @@ class Plugin_Records {
} }
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['rank'] . '.$> Local Record: ' . $message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['rank'] . '.$> Local Record: ' .
Tools::formatTime($newRecord['time']); Tools::formatTime($newRecord['time']);
$this->iControl->chat->sendInformation($message); $this->mc->chat->sendInformation($message);
$this->updateManialinks[self::MLID_LOCAL] = true; $this->updateManialinks[self::MLID_LOCAL] = true;
} }
} }
@ -745,7 +745,7 @@ class Plugin_Records {
} }
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] . $message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] .
'.$> Dedimania Record: ' . Tools::formatTime($newRecord['Best']); '.$> Dedimania Record: ' . Tools::formatTime($newRecord['Best']);
$this->iControl->chat->sendInformation($message); $this->mc->chat->sendInformation($message);
$this->updateManialinks[self::MLID_DEDI] = true; $this->updateManialinks[self::MLID_DEDI] = true;
} }
} }
@ -859,21 +859,21 @@ class Plugin_Records {
if (!$record || !$this->settings->dedimania_enabled) return; if (!$record || !$this->settings->dedimania_enabled) return;
// Set validation replay // Set validation replay
$validationReplay = $this->iControl->server->getValidationReplay($record['Login']); $validationReplay = $this->mc->server->getValidationReplay($record['Login']);
if ($validationReplay) $record['VReplay'] = $validationReplay; if ($validationReplay) $record['VReplay'] = $validationReplay;
// Set ghost replay // Set ghost replay
if ($record['Rank'] <= 1) { if ($record['Rank'] <= 1) {
$dataDirectory = $this->iControl->server->getDataDirectory(); $dataDirectory = $this->mc->server->getDataDirectory();
if (!isset($this->dedimaniaData['directoryAccessChecked'])) { if (!isset($this->dedimaniaData['directoryAccessChecked'])) {
$access = $this->iControl->server->checkAccess($dataDirectory); $access = $this->mc->server->checkAccess($dataDirectory);
if (!$access) { if (!$access) {
trigger_error("No access to the servers data directory. Can't retrieve ghost replays."); trigger_error("No access to the servers data directory. Can't retrieve ghost replays.");
} }
$this->dedimaniaData['directoryAccessChecked'] = $access; $this->dedimaniaData['directoryAccessChecked'] = $access;
} }
if ($this->dedimaniaData['directoryAccessChecked']) { if ($this->dedimaniaData['directoryAccessChecked']) {
$ghostReplay = $this->iControl->server->getGhostReplay($record['Login']); $ghostReplay = $this->mc->server->getGhostReplay($record['Login']);
if ($ghostReplay) $record['Top1GReplay'] = $ghostReplay; if ($ghostReplay) $record['Top1GReplay'] = $ghostReplay;
} }
} }
@ -939,15 +939,15 @@ class Plugin_Records {
* Send manialink to clients * Send manialink to clients
*/ */
private function sendManialink($manialink, $login = null) { private function sendManialink($manialink, $login = null) {
if (!$manialink || !$this->iControl->client) return; if (!$manialink || !$this->mc->client) return;
if (!$login) { if (!$login) {
if (!$this->iControl->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) { if (!$this->mc->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) {
trigger_error("Couldn't send manialink to players. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send manialink to players. " . $this->mc->getClientErrorText());
} }
} }
else { else {
if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) { if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) {
trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->mc->getClientErrorText());
} }
} }
} }
@ -967,7 +967,7 @@ class Plugin_Records {
* Update local records manialink * Update local records manialink
*/ */
private function buildLocalManialink() { private function buildLocalManialink() {
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if (!$map) { if (!$map) {
return null; return null;
} }
@ -1146,12 +1146,12 @@ class Plugin_Records {
private function getLocalRecords($mapUId, $limit = -1) { private function getLocalRecords($mapUId, $limit = -1) {
$query = "SELECT * FROM ( $query = "SELECT * FROM (
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
WHERE recs.`mapUId` = '" . $this->iControl->database->escape($mapUId) . "' WHERE recs.`mapUId` = '" . $this->mc->database->escape($mapUId) . "'
ORDER BY recs.`time` ASC ORDER BY recs.`time` ASC
" . ($limit > 0 ? "LIMIT " . $limit : "") . ") records " . ($limit > 0 ? "LIMIT " . $limit : "") . ") records
LEFT JOIN `" . Database::TABLE_PLAYERS . "` players LEFT JOIN `" . Database::TABLE_PLAYERS . "` players
ON records.`Login` = players.`Login`;"; ON records.`Login` = players.`Login`;";
return $this->iControl->database->query($query); return $this->mc->database->query($query);
} }
/** /**
@ -1163,7 +1163,7 @@ class Plugin_Records {
*/ */
private function getLocalRecord($mapUId, $login) { private function getLocalRecord($mapUId, $login) {
if (!$mapUId || !$login) return null; if (!$mapUId || !$login) return null;
$database = $this->iControl->database; $database = $this->mc->database;
$query = "SELECT records.* FROM ( $query = "SELECT records.* FROM (
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` `recs`, (SELECT @rank := 0) r SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` `recs`, (SELECT @rank := 0) r
WHERE recs.`mapUid` = '" . $database->escape($mapUId) . "' WHERE recs.`mapUid` = '" . $database->escape($mapUId) . "'

View File

@ -23,7 +23,7 @@ class Plugin_United {
/** /**
* Private properties * Private properties
*/ */
private $mControl = null; private $mc = null;
private $config = null; private $config = null;
@ -46,8 +46,8 @@ class Plugin_United {
/** /**
* Constuct plugin * Constuct plugin
*/ */
public function __construct($mControl) { public function __construct($mc) {
$this->mControl = $mControl; $this->mc = $mc;
// Load config // Load config
$this->config = Tools::loadConfig('united.plugin.xml'); $this->config = Tools::loadConfig('united.plugin.xml');
@ -60,14 +60,14 @@ class Plugin_United {
$this->loadClients(); $this->loadClients();
// Register for callbacks // Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, $this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer'); 'handleManialinkPageAnswer');
// Register for commands // Register for commands
$this->iControl->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand'); $this->mc->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand');
if ($this->settings->widgets_enabled) { if ($this->settings->widgets_enabled) {
// Build addfavorite manialink // Build addfavorite manialink
@ -88,9 +88,9 @@ class Plugin_United {
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) { if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
// Send favorite widget // Send favorite widget
if (!$this->iControl->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0, if (!$this->mc->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0,
false)) { false)) {
trigger_error("Couldn't send favorite widget! " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send favorite widget! " . $this->mc->getClientErrorText());
} }
} }
} }
@ -106,7 +106,7 @@ class Plugin_United {
$this->settings->enabled = Tools::toBool($this->config->enabled); $this->settings->enabled = Tools::toBool($this->config->enabled);
// Timeout // Timeout
$timeout = $this->iControl->server->config->xpath('timeout'); $timeout = $this->mc->server->config->xpath('timeout');
if ($timeout) { if ($timeout) {
$this->settings->timeout = (int) $timeout[0]; $this->settings->timeout = (int) $timeout[0];
} }
@ -169,7 +169,7 @@ class Plugin_United {
$client->readCB(); $client->readCB();
$callbacks = $client->getCBResponses(); $callbacks = $client->getCBResponses();
if (!is_array($callbacks) || $client->isError()) { if (!is_array($callbacks) || $client->isError()) {
trigger_error("Error reading server callbacks! " . $this->iControl->getClientErrorText($client)); trigger_error("Error reading server callbacks! " . $this->mc->getClientErrorText($client));
} }
else { else {
if ($client == $currentServer) { if ($client == $currentServer) {
@ -189,7 +189,7 @@ class Plugin_United {
$this->lastStatusCheck = time(); $this->lastStatusCheck = time();
if (!$client->query('CheckEndMatchCondition')) { if (!$client->query('CheckEndMatchCondition')) {
trigger_error("Couldn't get game server status. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't get game server status. " . $this->mc->getClientErrorText($client));
} }
else { else {
$response = $client->getResponse(); $response = $client->getResponse();
@ -241,7 +241,7 @@ class Plugin_United {
*/ */
public function handle5Seconds($callback = null) { public function handle5Seconds($callback = null) {
// Update lobby infos // Update lobby infos
$players = $this->iControl->server->getPlayers(); $players = $this->mc->server->getPlayers();
if (is_array($players)) { if (is_array($players)) {
$playerCount = count($players); $playerCount = count($players);
$playerLevel = 0.; $playerLevel = 0.;
@ -253,7 +253,7 @@ class Plugin_United {
} }
foreach ($this->lobbies as $lobby) { foreach ($this->lobbies as $lobby) {
if (!$lobby->query('SetLobbyInfo', true, $playerCount, 255, $playerLevel)) { if (!$lobby->query('SetLobbyInfo', true, $playerCount, 255, $playerLevel)) {
trigger_error("Couldn't update lobby info. " . $this->iControl->getClientErrorText($lobby)); trigger_error("Couldn't update lobby info. " . $this->mc->getClientErrorText($lobby));
} }
} }
} }
@ -263,14 +263,14 @@ class Plugin_United {
$joinLink = $this->getJoinLink(); $joinLink = $this->getJoinLink();
foreach ($clients as $client) { foreach ($clients as $client) {
if ($client == $this->gameServer[$this->currentClientIndex]) continue; if ($client == $this->gameServer[$this->currentClientIndex]) continue;
$players = $this->iControl->server->getPlayers($client); $players = $this->mc->server->getPlayers($client);
if (!is_array($players)) continue; if (!is_array($players)) continue;
foreach ($players as $player) { foreach ($players as $player) {
$login = $player['Login']; $login = $player['Login'];
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) { if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
trigger_error( trigger_error(
"Couldn't redirect player '" . $login . "' to active game server. " . "Couldn't redirect player '" . $login . "' to active game server. " .
$this->iControl->getClientErrorText($client)); $this->mc->getClientErrorText($client));
} }
} }
} }
@ -291,28 +291,28 @@ class Plugin_United {
if ($add_all) { if ($add_all) {
// Add all server // Add all server
foreach ($this->gameServer as $serverClient) { foreach ($this->gameServer as $serverClient) {
array_push($serverLogins, $this->iControl->server->getLogin($serverClient)); array_push($serverLogins, $this->mc->server->getLogin($serverClient));
} }
foreach ($this->lobbies as $serverClient) { foreach ($this->lobbies as $serverClient) {
array_push($serverLogins, $this->iControl->server->getLogin($serverClient)); array_push($serverLogins, $this->mc->server->getLogin($serverClient));
} }
} }
else { else {
// Add only current server // Add only current server
array_push($serverLogins, $this->iControl->server->getLogin()); array_push($serverLogins, $this->mc->server->getLogin());
} }
// Build manialink url // Build manialink url
$manialink = 'iControl?favorite'; $manialink = 'mc?favorite';
foreach ($serverLogins as $serverLogin) { foreach ($serverLogins as $serverLogin) {
$manialink .= '&' . $serverLogin; $manialink .= '&' . $serverLogin;
} }
// Send url to player // Send url to player
if (!$this->iControl->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) { if (!$this->mc->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) {
trigger_error( trigger_error(
"Couldn't open manialink to add server to favorite for '" . $login . "'! " . "Couldn't open manialink to add server to favorite for '" . $login . "'! " .
$this->iControl->getClientErrorText()); $this->mc->getClientErrorText());
} }
break; break;
} }
@ -345,39 +345,39 @@ class Plugin_United {
// Restart map on next game server // Restart map on next game server
if (!$newClient->query('RestartMap')) { if (!$newClient->query('RestartMap')) {
trigger_error("Couldn't restart map on next game server. " . $this->iControl->getClientErrorText($newClient)); trigger_error("Couldn't restart map on next game server. " . $this->mc->getClientErrorText($newClient));
} }
if ($simulateMapEnd) { if ($simulateMapEnd) {
// Simulate EndMap on old client // Simulate EndMap on old client
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP)); $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP));
} }
// Transfer players to next server // Transfer players to next server
$joinLink = $this->getJoinLink($newClient); $joinLink = $this->getJoinLink($newClient);
if (!$oldClient->query('GetPlayerList', 255, 0)) { if (!$oldClient->query('GetPlayerList', 255, 0)) {
trigger_error("Couldn't get player list. " . $this->iControl->getClientErrorText($oldClient)); trigger_error("Couldn't get player list. " . $this->mc->getClientErrorText($oldClient));
} }
else { else {
$playerList = $oldClient->getResponse(); $playerList = $oldClient->getResponse();
foreach ($playerList as $player) { foreach ($playerList as $player) {
$login = $player['Login']; $login = $player['Login'];
if (!$oldClient->query('SendOpenLinkToLogin', $login, $joinLink, 1)) { if (!$oldClient->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
trigger_error("Couldn't redirect player to next game server. " . $this->iControl->getClientErrorText($oldClient)); trigger_error("Couldn't redirect player to next game server. " . $this->mc->getClientErrorText($oldClient));
} }
} }
$this->iControl->client = $newClient; $this->mc->client = $newClient;
} }
// Trigger client updated callback // Trigger client updated callback
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer"); $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer");
if ($simulateMapEnd) { if ($simulateMapEnd) {
// Simulate BeginMap on new client // Simulate BeginMap on new client
$map = $this->iControl->server->getMap(); $map = $this->mc->server->getMap();
if ($map) { if ($map) {
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map))); $this->mc->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map)));
} }
} }
} }
@ -391,9 +391,9 @@ class Plugin_United {
if (!$command) return; if (!$command) return;
$login = $command[1][1]; $login = $command[1][1];
if (!$this->iControl->authentication->checkRight($login, 'operator')) { if (!$this->mc->authentication->checkRight($login, 'operator')) {
// Not allowed // Not allowed
$this->iControl->authentication->sendNotAllowed($login); $this->mc->authentication->sendNotAllowed($login);
return; return;
} }
@ -401,7 +401,7 @@ class Plugin_United {
$this->switchServerRequested = time() + 3; $this->switchServerRequested = time() + 3;
// Send chat message // Send chat message
$this->iControl->chat->sendInformation("Switching to next server in 3 seconds..."); $this->mc->chat->sendInformation("Switching to next server in 3 seconds...");
} }
/** /**
@ -418,7 +418,7 @@ class Plugin_United {
$joinLink = $this->getJoinLink($gameserver, !$data[1]); $joinLink = $this->getJoinLink($gameserver, !$data[1]);
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) { if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
trigger_error( trigger_error(
"United Plugin: Couldn't redirect player to current game server. " . $this->iControl->getClientErrorText($client)); "United Plugin: Couldn't redirect player to current game server. " . $this->mc->getClientErrorText($client));
} }
} }
@ -473,7 +473,7 @@ class Plugin_United {
} }
// Wait for server to be ready // Wait for server to be ready
if (!$this->iControl->server->waitForStatus($client, 4)) { if (!$this->mc->server->waitForStatus($client, 4)) {
trigger_error("Server couldn't get ready!", E_USER_ERROR); trigger_error("Server couldn't get ready!", E_USER_ERROR);
} }
@ -481,7 +481,7 @@ class Plugin_United {
if (!$client->query('SetApiVersion', ManiaControl::API_VERSION)) { if (!$client->query('SetApiVersion', ManiaControl::API_VERSION)) {
trigger_error( trigger_error(
"Couldn't set API version '" . ManiaControl::API_VERSION . "'! This might cause problems. " . "Couldn't set API version '" . ManiaControl::API_VERSION . "'! This might cause problems. " .
$this->iControl->getClientErrorText($client)); $this->mc->getClientErrorText($client));
} }
// Set server settings // Set server settings
@ -489,30 +489,30 @@ class Plugin_United {
$hideServer = ($isGameServer && $this->settings->hide_game_server ? 1 : 0); $hideServer = ($isGameServer && $this->settings->hide_game_server ? 1 : 0);
// Passwords // Passwords
if (!$client->query('SetServerPassword', $password)) { if (!$client->query('SetServerPassword', $password)) {
trigger_error("Couldn't set server join password. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't set server join password. " . $this->mc->getClientErrorText($client));
} }
if (!$client->query('SetServerPasswordForSpectator', $password)) { if (!$client->query('SetServerPasswordForSpectator', $password)) {
trigger_error("Couldn't set server spec password. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't set server spec password. " . $this->mc->getClientErrorText($client));
} }
// Show/Hide server // Show/Hide server
if (!$client->query('SetHideServer', $hideServer)) { if (!$client->query('SetHideServer', $hideServer)) {
trigger_error( trigger_error(
"Couldn't set server '" . ($hideServer == 0 ? 'shown' : 'hidden') . "'. " . "Couldn't set server '" . ($hideServer == 0 ? 'shown' : 'hidden') . "'. " .
$this->iControl->getClientErrorText($client)); $this->mc->getClientErrorText($client));
} }
// Enable service announces // Enable service announces
if (!$client->query("DisableServiceAnnounces", false)) { if (!$client->query("DisableServiceAnnounces", false)) {
trigger_error("Couldn't enable service announces. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't enable service announces. " . $this->mc->getClientErrorText($client));
} }
// Set game mode // Set game mode
if (!$client->query('SetGameMode', $this->settings->gamemode)) { if (!$client->query('SetGameMode', $this->settings->gamemode)) {
trigger_error( trigger_error(
"Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->iControl->getClientErrorText($client)); "Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->mc->getClientErrorText($client));
} }
else if (!$client->query('RestartMap')) { else if (!$client->query('RestartMap')) {
trigger_error("Couldn't restart map to change game mode. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't restart map to change game mode. " . $this->mc->getClientErrorText($client));
} }
// Save client // Save client
@ -520,7 +520,7 @@ class Plugin_United {
if ($isGameServer) { if ($isGameServer) {
array_push($this->gameServer, $client); array_push($this->gameServer, $client);
if (count($this->gameServer) === 1) { if (count($this->gameServer) === 1) {
$this->iControl->client = $client; $this->mc->client = $client;
} }
} }
else { else {
@ -543,9 +543,9 @@ class Plugin_United {
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) { if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
// Send favorite widget // Send favorite widget
if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login, if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login,
$this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0, false)) { $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0, false)) {
trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->iControl->getClientErrorText()); trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->mc->getClientErrorText());
} }
} }
} }
@ -559,14 +559,14 @@ class Plugin_United {
$client = $this->gameServer[$this->currentClientIndex]; $client = $this->gameServer[$this->currentClientIndex];
} }
if (!$client->query('GetSystemInfo')) { if (!$client->query('GetSystemInfo')) {
trigger_error("Couldn't fetch server system info. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't fetch server system info. " . $this->mc->getClientErrorText($client));
return null; return null;
} }
else { else {
$systemInfo = $client->getResponse(); $systemInfo = $client->getResponse();
$password = ''; $password = '';
if (!$client->query('GetServerPassword')) { if (!$client->query('GetServerPassword')) {
trigger_error("Couldn't get server password. " . $this->iControl->getClientErrorText($client)); trigger_error("Couldn't get server password. " . $this->mc->getClientErrorText($client));
} }
else { else {
$password = $client->getResponse(); $password = $client->getResponse();

View File

@ -1,6 +1,6 @@
********************************************** **********************************************
* * * *
* mControl ManiaPlanet Server Control * * mc ManiaPlanet Server Control *
* Written by steeffeen * * Written by steeffeen *
* Contact: mail@steeffeen.com * * Contact: mail@steeffeen.com *
* * * *
@ -12,30 +12,30 @@ SETUP:
2. Configure the needed settings: 2. Configure the needed settings:
2.1 Open the file 'configs/server.mControl.xml'. 2.1 Open the file 'configs/server.mc.xml'.
Enter your maniaplanet server information. Enter your maniaplanet server information.
2.2 Open the file 'configs/database.mControl.xml' 2.2 Open the file 'configs/database.mc.xml'
Enter your mysql server information or disable database usage if you don't have a mysql server available. Enter your mysql server information or disable database usage if you don't have a mysql server available.
2.3 Open the file 'configs/authentication.mControl.xml'. 2.3 Open the file 'configs/authentication.mc.xml'.
Add the player logins who should have access to the commands of mControl. Add the player logins who should have access to the commands of mc.
3. (Optional) Enable or disable the available plugins in the file 'configs/plugins.mControl.xml'. 3. (Optional) Enable or disable the available plugins in the file 'configs/plugins.mc.xml'.
4. (Optional) Edit the other config files in 'configs/' in order to customize your mControl to fit your needs. 4. (Optional) Edit the other config files in 'configs/' in order to customize your mc to fit your needs.
5. Run the tool via the shell script 'mControl.sh' (UNIX) or the batch file 'mControl.bat' (Windows) 5. Run the tool via the shell script 'mc.sh' (UNIX) or the batch file 'mc.bat' (Windows)
6. Enjoy! 6. Enjoy!
INFORMATION: INFORMATION:
- mControl is only tested on UNIX machines - mc is only tested on UNIX machines
- even though it might run properly on Windows I can't promise it will work all the time - even though it might run properly on Windows I can't promise it will work all the time
- furthermore I can't promise that there won't be a feature in the future that makes it impossible to run mControl under Windows - furthermore I can't promise that there won't be a feature in the future that makes it impossible to run mc under Windows
- in order to run mControl under Windows you have to alter the file mControl.bat and enter the path to your php.exe - in order to run mc under Windows you have to alter the file mc.bat and enter the path to your php.exe
- Tests were performed using PHP Version 5.4 - Tests were performed using PHP Version 5.4
- If you notice problems with other version please let me know - If you notice problems with other version please let me know