├── .gitignore ├── LICENSE ├── README.md ├── docker ├── Dockerfile ├── Readme.md ├── cronjob.txt ├── nginx_default ├── php.ini ├── start.sh └── sudoers ├── factorio ├── 3RaFactorioBot.js ├── config.json ├── manage.c ├── manage.sh └── server1 │ ├── banlist.json │ ├── chatlog.0 │ ├── config │ └── config.ini │ ├── mods │ └── mod-list.json │ ├── player-data.json │ ├── saves │ ├── sample.zip │ └── sample2024.zip │ ├── screenlog.0 │ └── server-settings.json ├── html ├── .htaccess ├── assets │ ├── api │ │ ├── console.php │ │ ├── cpumeminfo.php │ │ ├── files_table.php │ │ └── login.php │ ├── css │ │ ├── base.css │ │ ├── customalerts.css │ │ ├── log-ui.css │ │ └── login.css │ ├── img │ │ ├── 3rabutton.png │ │ ├── asc.gif │ │ ├── bg.gif │ │ └── desc.gif │ ├── jquery-3.1.1.min.js │ ├── js │ │ ├── base.js │ │ ├── console.js │ │ ├── cpumeminfo.js │ │ ├── customalerts.js │ │ └── log-ui.js │ └── modules │ │ ├── files_archive.php │ │ ├── files_delete.php │ │ ├── files_download.php │ │ ├── files_upload.php │ │ ├── gameServer_forceKill.php │ │ ├── gameServer_sendCommand.php │ │ ├── gameServer_start.php │ │ ├── gameServer_status.php │ │ ├── gameServer_stop.php │ │ ├── logs_download.php │ │ └── logs_list.php ├── files.php ├── getserver.php ├── index.php ├── login.php ├── logs.php ├── process.php ├── server-settings.php ├── update.sh ├── update_web_control.php └── version_manager.php ├── install.sh └── users.txt /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | ################# 32 | ## PhpStorm 33 | ################ 34 | 35 | .idea/ 36 | 37 | 38 | ################# 39 | ## Visual Studio 40 | ################# 41 | 42 | ## Ignore Visual Studio temporary files, build results, and 43 | ## files generated by popular Visual Studio add-ons. 44 | 45 | # User-specific files 46 | *.suo 47 | *.user 48 | *.sln.docstates 49 | 50 | # Build results 51 | 52 | [Dd]ebug/ 53 | [Rr]elease/ 54 | x64/ 55 | build/ 56 | [Bb]in/ 57 | [Oo]bj/ 58 | 59 | # MSTest test Results 60 | [Tt]est[Rr]esult*/ 61 | [Bb]uild[Ll]og.* 62 | 63 | *_i.c 64 | *_p.c 65 | *.ilk 66 | *.meta 67 | *.obj 68 | *.pch 69 | *.pdb 70 | *.pgc 71 | *.pgd 72 | *.rsp 73 | *.sbr 74 | *.tlb 75 | *.tli 76 | *.tlh 77 | *.tmp 78 | *.tmp_proj 79 | *.log 80 | *.vspscc 81 | *.vssscc 82 | .builds 83 | *.pidb 84 | *.log 85 | *.scc 86 | 87 | # Visual C++ cache files 88 | ipch/ 89 | *.aps 90 | *.ncb 91 | *.opensdf 92 | *.sdf 93 | *.cachefile 94 | 95 | # Visual Studio profiler 96 | *.psess 97 | *.vsp 98 | *.vspx 99 | 100 | # Guidance Automation Toolkit 101 | *.gpState 102 | 103 | # ReSharper is a .NET coding add-in 104 | _ReSharper*/ 105 | *.[Rr]e[Ss]harper 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | *.ncrunch* 115 | .*crunch*.local.xml 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.Publish.xml 135 | *.pubxml 136 | *.publishproj 137 | 138 | # NuGet Packages Directory 139 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 140 | #packages/ 141 | 142 | # Windows Azure Build Output 143 | csx 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.[Pp]ublish.xml 158 | *.pfx 159 | *.publishsettings 160 | 161 | # RIA/Silverlight projects 162 | Generated_Code/ 163 | 164 | # Backup & report files from converting an old project file to a newer 165 | # Visual Studio version. Backup files are not needed, because we have git ;-) 166 | _UpgradeReport_Files/ 167 | Backup*/ 168 | UpgradeLog*.XML 169 | UpgradeLog*.htm 170 | 171 | # SQL Server files 172 | App_Data/*.mdf 173 | App_Data/*.ldf 174 | 175 | ############# 176 | ## Windows detritus 177 | ############# 178 | 179 | # Windows image file caches 180 | Thumbs.db 181 | ehthumbs.db 182 | 183 | # Folder config file 184 | Desktop.ini 185 | 186 | # Recycle Bin used on file shares 187 | $RECYCLE.BIN/ 188 | 189 | # Mac crap 190 | .DS_Store 191 | 192 | 193 | ############# 194 | ## Python 195 | ############# 196 | 197 | *.py[cod] 198 | 199 | # Packages 200 | *.egg 201 | *.egg-info 202 | dist/ 203 | build/ 204 | eggs/ 205 | parts/ 206 | var/ 207 | sdist/ 208 | develop-eggs/ 209 | .installed.cfg 210 | 211 | # Installer logs 212 | pip-log.txt 213 | 214 | # Unit test / coverage reports 215 | .coverage 216 | .tox 217 | 218 | #Translations 219 | *.mo 220 | 221 | #Mr Developer 222 | .mr.developer.cfg 223 | 224 | 225 | ############# 226 | ## Custom 227 | ############# 228 | 229 | # Compiled file manage file 230 | factorio/managepgm 231 | 232 | # NodeJS/Discord.js 233 | factorio/node_modules/ 234 | 235 | # Bot Config File 236 | factorio/config.json 237 | 238 | # Bot Save Data List (Channel List, Player Lists, Registration List) 239 | factorio/savedata.json 240 | 241 | # Log File 242 | factorio/screenlog.0 243 | 244 | 245 | /Web_Control.phpproj 246 | /Web_Control.sln 247 | /factorio/.vs/factorio/v15 248 | *.sln 249 | *.vcxproj 250 | /.vs/Web_Control/v15/Browse.VC.db 251 | /.vs/Web_Control/v15/Browse.VC.opendb 252 | /.vs/config 253 | /.vs/Web_Control/v15 254 | *.njsproj 255 | /html/vwd.webinfo 256 | /html/Web.config 257 | *.phpproj 258 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Web_Control 2 | Web accessible server management. Start/Stop servers, upload/delete save files, chat with active servers, edit server settings, download log files, and more! Discord auth is available for web control logins. There are two levels of login: Admin (can update Web-Control with click of a button) and Moderator (cannot update web-control). All user actions are logged, and log files cannot be removed from the web interface. More permission adjustment is in the works. View our trello (https://trello.com/b/QP2fuOXj/web-control) for project status and plans. A more detailed guide to the web control is in the works here: http://3ragaming.com/faq/web_control/ 3 | 4 | Game, Web server, and discord bot must on the same server (for now). 5 | 6 | # Requirements 7 | configure the sudoers file to allow www-data access to screen and gcc or else you will be unable to start the factorio server from the web control 8 | 9 | `www-data ALL=(ALL:ALL) /usr/bin/screen *` 10 | 11 | `www-data ALL=(ALL:ALL) /usr/bin/gcc *` 12 | 13 | 14 | Easy Install! Put this line into your SSH terminal to begin the install: 15 | 16 | `bash <(curl -s https://raw.githubusercontent.com/3RaGaming/Web_Control/master/install.sh)` 17 | 18 | This will run you through the entire setup process. Once the program is installed on the server, you'll be instructed on how to access the web gui to continue the rest of the configuration. 19 | 20 | # Dependencies 21 | 22 | Ubuntu 20.04 (or any other linux of your choosing, if you have the know-how to figure it out) 23 | 24 | Apache2 with SSL Enabled. (Web Control is currently set to only work on a an https connection) 25 | 26 | php7 with cURL, zip, json 27 | 28 | gnu "screen" (apt install screen) 29 | 30 | gcc and npm 31 | 32 | zip, unzip, tar, and xz-utils 33 | 34 | crontab (apt install cron, specifically) 35 | 36 | Node.js v16.4.0 or higher (https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) 37 | 38 | Since we run with GNU Screen, php will need sudo access to function correctly this requirement is partially why a docker install is nice 39 | 40 | # Manual Installation 41 | 42 | If you prefer to do it manually, here are the steps. Right now the file path dependencies are as follows: 43 | /var/www/html for the web files 44 | /var/www/factorio for the server save locations. 45 | /usr/share/factorio/1.1.53 for the factorio instance itself 46 | (each factorio server version should be in it's own appropriately named folder) 47 | Basically, you should treat /var/www/ as the root directory for all web_control repo files. 48 | 49 | To compile the manage.c program, you must install gcc. 50 | 1) Open a Terminal window and navigate to `cd /var/www/factorio` 51 | 52 | 2) Run the command `gcc -o managepgm -std=gnu99 -pthread manage.c` (On success, nothing should appear in the terminal. If an error message appears, message zackman0010 with the error message.) 53 | 54 | 3) Run the command `npm i --save --no-optional discord.js` (If a message appears saying missing requirements, ignore it. It's only the voice server parts, which are not used in this program) 55 | 56 | Once the server files are all installed, and you have web access, there is a button at the top of the page to update from the master repo. This will easily keep your server up to date. 57 | We recommend following our updates, as if a recompile of the manage.c is ever necessary, you may need to restart your factorio servers. 58 | 59 | # Docker Build Installation 60 | 61 | `docker build -t factorio .` 62 | `docker run -dt --restart unless-stopped --name factorio factorio` Exposed ports are set in the docker file. If you need alternate ones, edit the docker file, or add them individually via `-p 8080:80/tcp` with the correct ports needed 63 | Nginx runs on port 8080 by default, so you'll need another proxy or port forward to expose this. This docker build uses 80 for unencrypted traffic only. If you want ssl, it's suggested to use an nginx reverse proxy that will handle the ssl. You'll also want to set the `client_max_body_size 100M;` setting in your config to allow large files to be uploaded. 64 | `docker exec -it factorio /bin/bash` Login to the server to check things 65 | 66 | # Finishing touches 67 | 68 | This install is currently dependant on a discord bot to function. You need to update `/var/www/factorio/config.json` before starting any factorio servers. 69 | You also need to update your factorio username and password(or, not both)token in each `/var/www/factorio/serverX/server-settings.json` file. We don't have easier forms for these yet. -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | EXPOSE 8080/tcp 3 | EXPOSE 34291/udp 4 | EXPOSE 34292/udp 5 | EXPOSE 34293/udp 6 | EXPOSE 34294/udp 7 | EXPOSE 34295/udp 8 | EXPOSE 34296/udp 9 | EXPOSE 34297/udp 10 | EXPOSE 34298/udp 11 | EXPOSE 34299/udp 12 | # 13 | # apt updates 14 | RUN apt update 15 | RUN apt upgrade -y 16 | RUN DEBIAN_FRONTEND=noninteractive TZ="US/Mountain" apt-get -y install tzdata 17 | RUN ln -sf /usr/share/zoneinfo/America/Denver /etc/localtime 18 | RUN echo "America/Denver" > /etc/timezone 19 | RUN apt install -y sudo apt-utils curl wget zip nano gcc libcjson-dev tar xz-utils screen cron nginx php8.3-fpm php-curl php-json php-zip 20 | # 21 | # install node 22 | RUN curl -sL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh 23 | RUN bash /tmp/nodesource_setup.sh 24 | RUN apt install -y nodejs 25 | RUN npm install -g npm 26 | # 27 | # copy files 28 | COPY nginx_default /etc/nginx/sites-enabled/default 29 | COPY start.sh /tmp/start.sh 30 | COPY cronjob.txt /tmp/cronjob.txt 31 | COPY php.ini /etc/php/8.3/fpm/php.ini 32 | COPY sudoers /etc/sudoers 33 | RUN chmod +x /tmp/start.sh 34 | # 35 | # create folders 36 | RUN rm -Rf /var/www/html 37 | RUN mkdir -p /var/www/html 38 | RUN mkdir -p /usr/share/factorio 39 | RUN mkdir -p /var/log/nginx 40 | RUN touch /var/log/nginx/all.log 41 | # 42 | # download, extract and install repo 43 | RUN wget https://gitlab.com/3RaGaming/Web_Control/-/archive/master/Web_Control-master.zip -O /tmp/master.zip 44 | RUN unzip /tmp/master.zip -d /tmp/ 45 | RUN mv /tmp/Web_Control-master/* /var/www/ 46 | RUN rm -Rf /tmp/master.zip /tmp/Web_Control-master/ 47 | RUN cd /var/www/factorio && gcc -o managepgm -std=gnu99 -pthread -I/usr/include/cjson manage.c -L/usr/lib/x86_64-linux-gnu -lcjson 48 | RUN cd /var/www/factorio && npm i --save --no-optional discord.js 49 | # 50 | # set file permissions 51 | RUN chown -R www-data:www-data /usr/share/factorio /var/www/ 52 | # 53 | # Other required tasks 54 | RUN crontab /tmp/cronjob.txt 55 | # 56 | # set command to start the container 57 | CMD /tmp/start.sh 58 | -------------------------------------------------------------------------------- /docker/Readme.md: -------------------------------------------------------------------------------- 1 | # Docker Install 2 | 3 | while in the docker folder, build the image 4 | 5 | ```bash 6 | cd ./docker 7 | docker build -t web_control . 8 | ``` 9 | 10 | then run the image 11 | ``` 12 | docker run -d --name web_control -p 8080:8080 -p 34291:34291/udp -p 34292:3429/udp2 -p 34293:34293/udp -p 34294:34294/udp -p 34295:34295/udp -p 34296:34296/udp -p 34297:34297/udp -p 34298:34298/udp -p 34299:34299/udp web_control 13 | ``` 14 | -------------------------------------------------------------------------------- /docker/cronjob.txt: -------------------------------------------------------------------------------- 1 | */1 * * * * chown -R www-data:www-data /var/www/ 2 | 0 22 * * * find /var/www/factorio/logs/* -mtime +10 -delete 3 | 1 22 * * * find /var/www/factorio/server*/logs/factorio-current-* -mtime +6 -delete 4 | 2 22 * * * find /var/www/factorio/server*/logs/screenlog-* -mtime +6 -delete 5 | 3 22 * * * find /var/www/factorio/server*/logs/z-chatlog-* -mtime +30 -delete 6 | 4 22 * * * find /var/www/factorio/server*/logs/file_deletion-* -mtime +10 -delete 7 | 5 22 * * * find /var/www/factorio/server*/logs/server-settings-update-* -mtime +10 -delete 8 | 9 | -------------------------------------------------------------------------------- /docker/nginx_default: -------------------------------------------------------------------------------- 1 | ## 2 | # Default server configuration 3 | # 4 | server { 5 | listen 8080 default_server; 6 | listen [::]:8080 default_server; 7 | 8 | # listen 443 ssl default_server; 9 | # listen [::]:443 ssl default_server; 10 | root /var/www/html; 11 | index index.html index.php; 12 | client_max_body_size 250M; 13 | access_log /var/log/nginx/all.log; 14 | error_log /var/log/nginx/all.log; 15 | 16 | server_name _; 17 | 18 | location / { 19 | try_files $uri $uri/ =404; 20 | } 21 | 22 | location ~ \.php$ { 23 | include snippets/fastcgi-php.conf; 24 | 25 | # With php-fpm (or other unix sockets): 26 | fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; 27 | } 28 | 29 | location ~ /assets/api/.*\.php$ { 30 | include snippets/fastcgi-php.conf; 31 | fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; 32 | access_log off; 33 | } 34 | 35 | location ~ /\.ht { 36 | deny all; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /docker/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | service nginx start 4 | service php8.3-fpm start 5 | service cron start 6 | echo STARTING 7 | tail -F /var/log/nginx/all.log 8 | 9 | -------------------------------------------------------------------------------- /docker/sudoers: -------------------------------------------------------------------------------- 1 | # 2 | # This file MUST be edited with the 'visudo' command as root. 3 | # 4 | # Please consider adding local content in /etc/sudoers.d/ instead of 5 | # directly modifying this file. 6 | # 7 | # See the man page for details on how to write a sudoers file. 8 | # 9 | Defaults env_reset 10 | Defaults mail_badpass 11 | Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" 12 | 13 | # Host alias specification 14 | 15 | # User alias specification 16 | 17 | # Cmnd alias specification 18 | 19 | # User privilege specification 20 | root ALL=(ALL:ALL) ALL 21 | 22 | # Members of the admin group may gain root privileges 23 | %admin ALL=(ALL) ALL 24 | 25 | # Allow members of group sudo to execute any command 26 | %sudo ALL=(ALL:ALL) ALL 27 | 28 | # See sudoers(5) for more information on "#include" directives: 29 | 30 | #includedir /etc/sudoers.d 31 | www-data ALL=(ALL:ALL) NOPASSWD:ALL -------------------------------------------------------------------------------- /factorio/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "botenabled": "false", 3 | "token": "PUT_YOUR_BOT_TOKEN_HERE", 4 | "clientid": "PUT_YOUR_BOT_CLIENT_ID_HERE", 5 | "clientsecret": "PUT_YOUR_BOT_CLIENT_SECRET_HERE", 6 | "guildid": "This is the ID of your guild", 7 | "adminrole": "This is the name of the role you wish to allow the webserver's admin permissions and the bot's eval command to", 8 | "modrole": "This is the name of the role you wish to lock the bot's admin commands to", 9 | "smallmodrole": "false", 10 | "gamemessage": "This is the bot's 'Currently Playing' message that appears below its name on Discord", 11 | "banreason": "Contact the server owner to appeal your ban", 12 | "update_descriptions": "false" 13 | } 14 | -------------------------------------------------------------------------------- /factorio/manage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dir_base="$( dirname "${BASH_SOURCE[0]}" )"; 3 | datetime=$(date +%F-%T) 4 | cd "$dir_base"; 5 | #put all recieved arguments into an $args[index] array 6 | args=("$@"); 7 | 8 | #used to clean certain variables 9 | function sanitize() { 10 | # first, strip underscores 11 | local work="$1" 12 | work=${work//_/}; 13 | # next, replace spaces with underscores 14 | work=${work// /_}; 15 | # now, clean out anything that's not alphanumeric or an underscore 16 | work=${work//[^.a-zA-Z0-9_\/]/}; 17 | # finally, lowercase with TR 18 | clean=`echo -n $work | tr A-Z a-z`; 19 | } 20 | 21 | #used to move server folder log files 22 | function move_logs() { 23 | local work="$1"; 24 | if [ ! -d "$1/logs" ]; then 25 | mkdir -p "$1/logs"; 26 | fi 27 | #Work in a screenlog archive here 28 | if [ -s "$1/screenlog.0" ]; then 29 | mv "$1/screenlog.0" "$1/logs/screenlog-${datetime}.log"; 30 | fi 31 | #Work in a chatlog archive here 32 | if [ -s "$1/chatlog.0" ]; then 33 | mv "$1/chatlog.0" "$1/logs/z-chatlog-${datetime}.log"; 34 | fi 35 | #Work in a factorio-current archive here 36 | if [ -s "$1/factorio-current.log" ]; then 37 | mv "$1/factorio-current.log" "$1/logs/factorio-current-${datetime}.log"; 38 | fi 39 | } 40 | 41 | #global way to get status of server. 42 | function get_status() { 43 | local work="$1"; 44 | firstcheck=$(sudo -u www-data screen -ls | grep manage | awk '$1=$1'); 45 | if [ "$firstcheck" ]; then 46 | sudo -u www-data screen -S manage -X at 0 stuff "${work}\\\$status\n"; 47 | secondcheck=$(tail -1 screenlog.0); 48 | sanitize "$secondcheck"; 49 | if [ "$clean" == "server_running" ]; then 50 | check="Server Running"; 51 | else 52 | check="Server Stopped"; 53 | fi 54 | else 55 | check="Manage Stopped"; 56 | fi 57 | } 58 | 59 | for dir in `ls -d */ | sed 's|/||'`; do 60 | sanitize "$dir"; 61 | if [ "$clean" == "${args[0]}" ]; then 62 | server="$clean"; 63 | fi 64 | done 65 | 66 | #accept the file path and string length here 67 | sanitize "${args[3]}"; 68 | program_path="$clean""/bin/x64/factorio"; 69 | 70 | if [ -z "$server" ]; then 71 | echo "Error in input"; 72 | else 73 | var_cont=true; 74 | ################################ 75 | #### Remove this when ready 76 | ################################ 77 | #server="factorio" 78 | dir_server="$dir_base/$server"; 79 | #echo "$dir_server" 80 | #important files 81 | #config/config.ini 82 | if [ ! -e "$dir_server/config/config.ini" ]; then 83 | echo "Missing config.ini"; var_cont=false; 84 | else 85 | port=$(echo "$dir_server" | grep -o -E '[0-9]+'); 86 | if [ -z "$port" ]; then 87 | port="0"; 88 | fi 89 | port="3429$port"; 90 | fi 91 | #server_settings.ini 92 | if [ ! -e "$dir_server/server-settings.json" ]; then echo "Missing server-settings.json"; var_cont=false; fi 93 | #player_data.json 94 | if [ ! -e "$dir_server/player-data.json" ]; then echo "Missing player-data.json"; var_cont=false; fi 95 | #banlist.json 96 | if [ ! -e "$dir_server/banlist.json" ]; then echo "Missing banlist.json"; var_cont=false; fi 97 | if [ -z "$port" ]; then echo "Port is incorrectly configured in config.ini"; fi 98 | #saves/ 99 | sanitize "${args[2]}"; 100 | cur_user="$clean"; 101 | sanitize "${args[1]}"; 102 | #cd $dir_server #This may need to be changed to the location of managepgm, not sure 103 | case "$clean" in 104 | 'prestart') 105 | get_status "$server"; 106 | if [ "$check" == "Server Running" ]; then 107 | #echo -e "${check}" 108 | echo "running" ; 109 | else 110 | echo "stopped"; 111 | fi 112 | ;; 113 | 'start') 114 | get_status "$server" 115 | if [ "$check" == "Server Running" ]; then 116 | echo -e "Attempted Start by $cur_user: Server is already running\r\n" >> $dir_server/screenlog.0 ; 117 | elif [ "$check" == "Manage Stopped" ]; then 118 | #Work in a screenlog archive here 119 | if [ -s "screenlog.0" ]; then 120 | mkdir -p logs; 121 | mv screenlog.0 logs/screenlog-${datetime}.log; 122 | fi 123 | #this is to check screen version to ensure compatability with newer version. 124 | #although... we don't know the exact version we need to be compatible with... 125 | screen_version=`screen -v | awk '{ print $NF }' | tr '-' ' '` 126 | sanitize "$screen_version" 127 | screen_version_yer=`echo "$clean" | tr '_' ' ' | awk '{ print $3 }'` 128 | screen_version_mon=`echo "$clean" | tr '_' ' ' | awk '{ print $2 }'` 129 | screen_version_day=`echo "$clean" | tr '_' ' ' | awk '{ print $1 }'` 130 | #messy, but the best I've got for now 131 | case "$screen_version_mon" in 132 | jan) screen_version_mon=01 ;; 133 | feb) screen_version_mon=02 ;; 134 | mar) screen_version_mon=03 ;; 135 | apr) screen_version_mon=04 ;; 136 | may) screen_version_mon=05 ;; 137 | jun) screen_version_mon=06 ;; 138 | jul) screen_version_mon=07 ;; 139 | aug) screen_version_mon=08 ;; 140 | sep) screen_version_mon=09 ;; 141 | oct) screen_version_mon=10 ;; 142 | nov) screen_version_mon=11 ;; 143 | dec) screen_version_mon=12 ;; 144 | esac 145 | screen_version="$screen_version_yer$screen_version_mon$screen_version_day"; 146 | if [ "$screen_version" -gt 161210 ]; then 147 | #Screen 4.6 or newer 148 | sudo -u www-data /usr/bin/screen -d -m -L -Logfile screenlog.0 -S manage ./managepgm; 149 | elif [ "$screen_version" -gt 150628 ]; then 150 | #Screen v4.5 151 | sudo -u www-data /usr/bin/screen -d -m -L screenlog.0 -S manage ./managepgm; 152 | else 153 | #Screen v4.4 or earlier 154 | sudo -u www-data /usr/bin/screen -d -m -L -S manage ./managepgm; 155 | fi 156 | sudo -u www-data /usr/bin/screen -r manage -X colon "log on^M"; 157 | sudo -u www-data /usr/bin/screen -r manage -X colon "logfile filename screenlog.0^M"; 158 | sudo -u www-data /usr/bin/screen -r manage -X colon "logfile flush 0^M"; 159 | sudo -u www-data /usr/bin/screen -r manage -X colon "multiuser on^M"; 160 | sudo -u www-data /usr/bin/screen -r manage -X colon "acladd root^M"; 161 | sudo -u www-data /usr/bin/screen -r manage -X colon "acladd user^M"; 162 | 163 | if [ "${args[3]}" ]; then 164 | sanitize "${args[3]}"; 165 | #only set $server_file if the file appears to be valid. 166 | #$server_file="$clean"; 167 | fi 168 | 169 | #Load server_file if it's set. Or else just load latest 170 | move_logs "$server"; 171 | if [ "$server_file" ]; then 172 | echo -e "Starting Server. ${server_file}. Initiated by $cur_user\r\n" >> $dir_server/screenlog.0 ; 173 | #sudo -u www-data screen -S manage -X at 0 stuff "${server}\\\$start\\\$true,${port},${dir_server},${program_path}\n" 174 | else 175 | echo -e "Starting Server. Load Latest. Initiated by $cur_user\r\n" >> $dir_server/screenlog.0 ; 176 | sudo -u www-data screen -S manage -X at 0 stuff "${server}\\\$start\\\$true,${port},${dir_server},${program_path}\n" 177 | fi 178 | else 179 | if [ "$var_cont" == false ] ; then 180 | echo "Cannot start server"; 181 | else 182 | if [ -e "$dir_server/server-settings.json" ]; then 183 | cp $dir_server/server-settings.json $dir_server/running-server-settings.json; 184 | fi 185 | if [ -e "$dir_server/screenlog.0" ]; then 186 | LASTSCREEN=$(tail -n 50 $dir_server/screenlog.0); 187 | move_logs "$server"; 188 | echo "${LASTSCREEN}" > $dir_server/screenlog.0 ; 189 | fi 190 | if [ -e "$dir_server/chatlog.0" ]; then 191 | LASTCHAT=$(tail -n 50 $dir_server/chatlog.0); 192 | echo "${LASTCHAT}" > $dir_server/chatlog.0 ; 193 | fi 194 | if [ "$server_file" ]; then 195 | echo -e "Starting Server. ${server_file}. Initiated by $cur_user\r\n" >> $dir_server/screenlog.0 ; 196 | #sudo -u www-data screen -S manage -X at 0 stuff "${server}\\\$start\\\$true,${port},${dir_server},${program_path}\n" 197 | else 198 | echo -e "Starting Server. Load Latest. Initiated by $cur_user\r\n" >> $dir_server/screenlog.0 ; 199 | sudo -u www-data screen -S manage -X at 0 stuff "${server}\\\$start\\\$true,${port},${dir_server},${program_path}\n" 200 | fi 201 | fi 202 | fi 203 | ;; 204 | 205 | 'stop') 206 | get_status "$server"; 207 | if [ "$check" == "Server Running" ]; then 208 | #echo "Server Shutting Down" ; 209 | echo -e "Server Shutting Down. Initiated by $cur_user\r\n" >> $dir_server/screenlog.0 ; 210 | if [ -e "$dir_server/running-server-settings.json" ]; then 211 | rm $dir_server/running-server-settings.json; 212 | fi 213 | sudo -u www-data screen -S manage -X at 0 stuff "${server}\\\$stop\n"; 214 | else 215 | echo "Server is already Stopped."; 216 | fi 217 | ;; 218 | 219 | 'status') 220 | get_status "$server"; 221 | if [ "$check" == "Server Running" ]; then 222 | echo "Server is Running" ; 223 | elif [ "$check" == "Manage Stopped" ]; then 224 | echo "Server Manager Not Running"; 225 | else 226 | echo "Server is Stopped"; 227 | fi 228 | ;; 229 | 230 | *) 231 | echo $"Usage: $0 server_select {start|stop|status} user"; 232 | exit 1 233 | esac 234 | fi 235 | -------------------------------------------------------------------------------- /factorio/server1/banlist.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "username": "exampleban", 4 | "reason": "This is an example ban" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /factorio/server1/chatlog.0: -------------------------------------------------------------------------------- 1 | This is an example chatlog.0 2 | -------------------------------------------------------------------------------- /factorio/server1/config/config.ini: -------------------------------------------------------------------------------- 1 | [path] 2 | read-data=/usr/share/factorio/1.1.53 3 | write-data=/var/www/factorio/server1 4 | [general] 5 | locale=en 6 | [other] 7 | tooltip_delay=0.0399999991 8 | max_threads=4 9 | force_default_logistic_filter_count_to_one=false 10 | show_tips_and_tricks=true 11 | autosort_inventory=true 12 | research_finished_stops_game=true 13 | use_item_groups=true 14 | use_item_subgroups=true 15 | output_console_delay=1200 16 | autosave_interval=10 17 | autosave_slots=5 18 | enable_new_mods=false 19 | port=34291 20 | use_version_filter_in_browse_games_gui=false 21 | check_updates=false 22 | enable_experimental_updates=false 23 | server_game_heartbeat_in_seconds=45 24 | lan_game_heartbeat_in_seconds=2 25 | proxy= 26 | verbose-logging=false 27 | minimum_latency_in_multiplayer=0 28 | [debug] 29 | force=enemy 30 | show_fps=basic 31 | show_detailed_info=basic 32 | show_time_used_percent=basic 33 | show_multiplayer_waiting_icon=basic 34 | show_multiplayer_statistics=basic 35 | show_tile_grid=full 36 | show_collision_rectangles=detailed 37 | show_selection_rectangles=detailed 38 | show_paths=full 39 | show_next_waypoint_bb=full 40 | show_target=full 41 | show_unit_group_info=full 42 | show_unit_behavior_info=full 43 | show_last_path_detail=full 44 | show_path_cache=full 45 | show_path_cache_paths=full 46 | show_rail_paths=full 47 | show_rolling_stock_count=full 48 | show_rail_connections=detailed 49 | show_rail_segments=detailed 50 | show_rail_joints=detailed 51 | show_train_stop_point=detailed 52 | show_train_braking_distance=full 53 | show_train_signals=full 54 | show_network_connected_entities=detailed 55 | show_circuit_network_numbers=detailed 56 | show_energy_sources_networks=detailed 57 | show_active_state=detailed 58 | show_pollution_values=full 59 | show_active_entities_on_chunk_counts=full 60 | show_active_chunks=full 61 | show_enemy_expansion_candidate_chunks=full 62 | show_enemy_expansion_candidate_chunk_values=full 63 | show_bad_attack_chunks=full 64 | show_tile_variations=full 65 | show_raw_tile_transitions=never 66 | show_tile_correction_previews=never 67 | show_fluid_box_fluid_info=basic 68 | show_environment_sound_info=basic 69 | show_logistic_robot_targets=full 70 | show_fire_info=full 71 | show_sticker_info=full 72 | [sound] 73 | master_volume=0.600000024 74 | ambient_volume=0.400000006 75 | game_effects_volume=0.699999988 76 | gui_effects_volume=0.699999988 77 | walking_volume=0.300000012 78 | environment_volume=0.449999988 79 | alert_volume=0.550000012 80 | audible_distance=40 81 | environment_audible_distance=15 82 | maximum_environment_sounds=15 83 | active_gui_volume_modifier=1.29999995 84 | active_gui_environment_volume_modifier=0.600000024 85 | ambient_music_pause_mean_seconds=45 86 | ambient_music_pause_variance_seconds=30 87 | ambient_music_mode=interleave-main-tracks-with-interludes 88 | [graphics] 89 | lights-render-quality=0.25 90 | custom-ui-scale=1 91 | multisampling-level=0 92 | preferred-screen-index=255 93 | screenshots_queue_size=10 94 | screenshots_threads_count=1 95 | debug_font_size=18 96 | max-texture-size=0 97 | fullscreen=false 98 | system-ui-scale=true 99 | show-minimap=true 100 | show-pollution-on-minimap=false 101 | show-pollution-on-large-map=true 102 | show-turret-radius-when-blueprinting=false 103 | show-item-labels-in-cursor=true 104 | show-grid-when-paused=true 105 | show-smoke=true 106 | show-clouds=true 107 | show-inserter-shadows=true 108 | show-inserter-arrows-when-selected=true 109 | show-inserter-arrows-when-detailed-info-is-on=false 110 | show-mining-drill-arrows-when-detailed-info-is-on=true 111 | show-combinator-settings-when-detailed-info-is-on=false 112 | force-opengl=false 113 | cache-sprite-atlas=false 114 | v-sync=false 115 | tree-sprite-mipmaps=true 116 | trilinear-filtering=true 117 | skip-vram-detection=false 118 | graphics-quality=normal 119 | video-memory-usage=low 120 | texture-compression=false 121 | disable-fma3=auto 122 | show-player-names-on-minimap=true 123 | -------------------------------------------------------------------------------- /factorio/server1/mods/mod-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "mods": [ 3 | { 4 | "name": "base", 5 | "enabled": "true" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /factorio/server1/player-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "available-campaign-levels": { 3 | "demo": { 4 | "level-01": "hard" 5 | }, 6 | "tight-spot": { 7 | "level-01": "hard" 8 | }, 9 | "transport-belt-madness": { 10 | "level-01": "hard" 11 | } 12 | }, 13 | "console-history": "", 14 | "latest-multiplayer-connections": "", 15 | "service-username": "", 16 | "service-token": "" 17 | } 18 | -------------------------------------------------------------------------------- /factorio/server1/saves/sample.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/factorio/server1/saves/sample.zip -------------------------------------------------------------------------------- /factorio/server1/saves/sample2024.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/factorio/server1/saves/sample2024.zip -------------------------------------------------------------------------------- /factorio/server1/screenlog.0: -------------------------------------------------------------------------------- 1 | This is an example screenlog.0 2 | -------------------------------------------------------------------------------- /factorio/server1/server-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Server Name", 3 | "description": "Server Description", 4 | "tags": ["testing", "no-joining"], 5 | 6 | "_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.", 7 | "max_players": 0, 8 | 9 | "_comment_visibility": ["public: Game will be published on the official Factorio matching server", 10 | "lan: Game will be broadcast on LAN"], 11 | "visibility": 12 | { 13 | "public": true, 14 | "lan": true 15 | }, 16 | 17 | "_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public", 18 | "username": "", 19 | "password": "", 20 | 21 | "_comment_token": "Authentication token. May be used instead of 'password' above.", 22 | "token": "", 23 | 24 | "game_password": "", 25 | 26 | "_comment_require_user_verification": "When set to true, the server will only allow clients that have a valid Factorio.com account", 27 | "require_user_verification": true, 28 | 29 | "_comment_max_upload_in_kilobytes_per_second" : "optional, default value is 0. 0 means unlimited.", 30 | "max_upload_in_kilobytes_per_second": 0, 31 | 32 | "_comment_minimum_latency_in_ticks": "optional one tick is 16ms in default speed, default value is 0. 0 means no minimum.", 33 | "minimum_latency_in_ticks": 0, 34 | 35 | "_comment_ignore_player_limit_for_returning_players": "Players that played on this map already can join even when the max player limit was reached.", 36 | "ignore_player_limit_for_returning_players": false, 37 | 38 | "_comment_allow_commands": "possible values are, true, false and admins-only", 39 | "allow_commands": "admins-only", 40 | 41 | "_comment_autosave_interval": "Autosave interval in minutes", 42 | "autosave_interval": 10, 43 | 44 | "_comment_autosave_slots": "server autosave slots, it is cycled through when the server autosaves.", 45 | "autosave_slots": 5, 46 | 47 | "_comment_afk_autokick_interval": "How many minutes until someone is kicked when doing nothing, 0 for never.", 48 | "afk_autokick_interval": 0, 49 | 50 | "_comment_auto_pause": "Whether should the server be paused when no players are present.", 51 | "auto_pause": true, 52 | 53 | "only_admins_can_pause_the_game": true, 54 | 55 | "_comment_autosave_only_on_server": "Whether autosaves should be saved only on server or also on all connected clients. Default is true.", 56 | "autosave_only_on_server": true, 57 | 58 | "_comment_non_blocking_saving": "Highly experimental feature, enable only at your own risk of losing your saves. On UNIX systems, server will fork itself to create an autosave. Autosaving on connected Windows clients will be disabled regardless of autosave_only_on_server option.", 59 | "non_blocking_saving": true, 60 | 61 | "_comment_admins": "List of case insensitive usernames, that will be promoted immediately", 62 | "admins": ["zackman0010"] 63 | } 64 | -------------------------------------------------------------------------------- /html/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Order Allow,Deny 3 | Deny from all 4 | 5 | -------------------------------------------------------------------------------- /html/assets/api/console.php: -------------------------------------------------------------------------------- 1 | ", "\\"); 19 | $repl=array("<", ">", ""); 20 | if($screen=="chat"&&file_exists($chatlog)) { 21 | $output = shell_exec('cat '.$chatlog.' | tail -n 75'); 22 | $output = str_replace($find, $repl, $output); 23 | echo str_replace(PHP_EOL, '', $output); //add newlines 24 | } elseif($screen=="console"&&file_exists($screenlog)) { 25 | $output = shell_exec('cat '.$screenlog.' | tail -n 75'); 26 | $output = str_replace($find, $repl, $output); 27 | echo str_replace(PHP_EOL, '', $output); //add newlines 28 | } 29 | } 30 | } 31 | } 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /html/assets/api/cpumeminfo.php: -------------------------------------------------------------------------------- 1 | $y) { 48 | $cpu[$x] = round($y / $total * 100, 1); 49 | } 50 | 51 | return $cpu; 52 | } 53 | 54 | $cpu = getCpuUsage(); 55 | $mem = getMem(); 56 | 57 | $results = array( 58 | 'cpu' => array( 59 | 'user'=> $cpu[0], 60 | 'nice'=> $cpu[1], 61 | 'sys'=> $cpu[2], 62 | 'idle'=> $cpu[3] 63 | ), 64 | 'mem' => $mem, 65 | ); 66 | 67 | echo json_encode($results); 68 | die(); 69 | ?> 70 | 71 | -------------------------------------------------------------------------------- /html/assets/api/files_table.php: -------------------------------------------------------------------------------- 1 | '; 29 | $tre=''; 30 | $tds=''; 31 | $tdc=''; 32 | $tde=''; 33 | 34 | if(isset($server_select)) { 35 | $full_dir="$base_dir$server_select/saves/"; 36 | $file_users_path = "$base_dir$server_select/saves.json"; 37 | if(file_exists($file_users_path)) { 38 | $jsonString = file_get_contents($file_users_path); 39 | $file_list = json_decode($jsonString, true); 40 | } 41 | 42 | foreach(array_diff(scandir("$full_dir"), array('..', '.')) as $file) { 43 | $file_full_path = "$full_dir$file"; 44 | $size = human_filesize("$file_full_path"); 45 | $date = date ("Y-m.M-d H:i:s", filemtime("$file_full_path")); 46 | if($user_level=="viewonly") { 47 | echo "$trs$tds $tdc $file $tdc $size $tdc $date $tdc "; 48 | } else { 49 | echo "$trs$tds $tdc $file $tdc $size $tdc $date $tdc "; 50 | } 51 | echo $file_list[$file] ?? "server"; 52 | echo " $tde $tre 53 | "; 54 | } 55 | } 56 | 57 | ?> -------------------------------------------------------------------------------- /html/assets/api/login.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /html/assets/css/base.css: -------------------------------------------------------------------------------- 1 | a:visited{ 2 | color:blue; 3 | } 4 | a:hover{ 5 | color:orange; 6 | } 7 | /* tables */ 8 | table.tablesorter { 9 | font-family:arial; 10 | background-color: #CDCDCD; 11 | margin:10px 0pt 15px; 12 | font-size: 8pt; 13 | width: 100%; 14 | text-align: left; 15 | } 16 | table.tablesorter thead tr th, table.tablesorter tfoot tr th { 17 | background-color: #e6EEEE; 18 | border: 1px solid #FFF; 19 | font-size: 8pt; 20 | padding: 4px; 21 | } 22 | table.tablesorter thead tr .header { 23 | background-image: url(../img/bg.gif); 24 | background-repeat: no-repeat; 25 | background-position: center right; 26 | cursor: pointer; 27 | } 28 | table.tablesorter tbody td { 29 | color: #3D3D3D; 30 | padding: 4px; 31 | background-color: #FFF; 32 | vertical-align: top; 33 | } 34 | table.tablesorter tbody tr.odd td { 35 | background-color:#F0F0F6; 36 | } 37 | table.tablesorter thead tr .headerSortUp { 38 | background-image: url(../img/asc.gif); 39 | } 40 | table.tablesorter thead tr .headerSortDown { 41 | background-image: url(../img/desc.gif); 42 | } 43 | table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { 44 | background-color: #8dbdd8; 45 | } 46 | -------------------------------------------------------------------------------- /html/assets/css/customalerts.css: -------------------------------------------------------------------------------- 1 | /* The Modal (background) */ 2 | .modal { 3 | display: none; /* Hidden by default */ 4 | position: fixed; /* Stay in place */ 5 | z-index: 1; /* Sit on top */ 6 | left: 0; 7 | top: 0; 8 | width: 100%; /* Full width */ 9 | height: 100%; /* Full height */ 10 | overflow: auto; /* Enable scroll if needed */ 11 | background-color: rgb(0,0,0); /* Fallback color */ 12 | background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ 13 | } 14 | 15 | /* Modal Content/Box */ 16 | .modal-content { 17 | background-color: #fefefe; 18 | margin: 5% auto 5% auto; /* 15% from the top and centered */ 19 | padding: 20px; 20 | border: 1px solid #888; 21 | width: 40%; 22 | overflow: scroll; 23 | overflow-x: hidden; 24 | max-height:70%; 25 | } 26 | .msg-col { 27 | display: inline-block; 28 | width: 70%; 29 | } 30 | .time-col { 31 | display: inline-block; 32 | width: 28%; 33 | } 34 | .time-col span { 35 | float: right; 36 | } 37 | .msg { 38 | padding: 4px 4px 4px 20px; 39 | margin-bottom: 4px; 40 | border: 1px solid transparent; 41 | border-radius: 4px; 42 | } 43 | .msg.info { 44 | color: #31708f; 45 | background-color: #d9edf7; 46 | border-color: #bce8f1; 47 | } 48 | .msg.warning { 49 | color: #8a6d3b; 50 | background-color: #fcf8e3; 51 | border-color: #faebcc; 52 | } 53 | .msg.error { 54 | color: #a94442; 55 | background-color: #f2dede; 56 | border-color: #ebccd1; 57 | } 58 | 59 | .reset { 60 | margin-right: 40px; 61 | color: #aaa; 62 | float: right; 63 | font-size: 12px; 64 | font-weight: bold; 65 | } 66 | .reset:hover, 67 | .reset:focus { 68 | color: black; 69 | text-decoration: none; 70 | cursor: pointer; 71 | } 72 | 73 | /* The Close Button */ 74 | .close { 75 | color: #aaa; 76 | float: right; 77 | font-size: 28px; 78 | font-weight: bold; 79 | } 80 | .close:hover, 81 | .close:focus { 82 | color: black; 83 | text-decoration: none; 84 | cursor: pointer; 85 | } -------------------------------------------------------------------------------- /html/assets/css/login.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Roboto:300); 2 | 3 | .login-page { 4 | width: 360px; 5 | padding: 8% 0 0; 6 | margin: auto; 7 | } 8 | .form { 9 | position: relative; 10 | z-index: 1; 11 | background: #FFFFFF; 12 | max-width: 360px; 13 | margin: 0 auto 100px; 14 | padding: 45px; 15 | text-align: center; 16 | box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24); 17 | } 18 | .form input { 19 | font-family: "Roboto", sans-serif; 20 | outline: 0; 21 | background: #f2f2f2; 22 | width: 100%; 23 | border: 0; 24 | margin: 0 0 15px; 25 | padding: 15px; 26 | box-sizing: border-box; 27 | font-size: 14px; 28 | } 29 | .form button { 30 | font-family: "Roboto", sans-serif; 31 | text-transform: uppercase; 32 | outline: 0; 33 | background: #4CAF50; 34 | width: 100%; 35 | border: 0; 36 | padding: 15px; 37 | color: #FFFFFF; 38 | font-size: 14px; 39 | -webkit-transition: all 0.3 ease; 40 | transition: all 0.3 ease; 41 | cursor: pointer; 42 | } 43 | .form button:hover,.form button:active,.form button:focus { 44 | background: #43A047; 45 | } 46 | .form .message { 47 | margin: 15px 0 0; 48 | color: #b3b3b3; 49 | font-size: 12px; 50 | } 51 | .form .message a { 52 | color: #4CAF50; 53 | text-decoration: none; 54 | } 55 | .form .register-form { 56 | display: none; 57 | } 58 | .container { 59 | position: relative; 60 | z-index: 1; 61 | max-width: 300px; 62 | margin: 0 auto; 63 | } 64 | .container:before, .container:after { 65 | content: ""; 66 | display: block; 67 | clear: both; 68 | } 69 | .container .info { 70 | margin: 50px auto; 71 | text-align: center; 72 | } 73 | .container .info h1 { 74 | margin: 0 0 15px; 75 | padding: 0; 76 | font-size: 36px; 77 | font-weight: 300; 78 | color: #1a1a1a; 79 | } 80 | .container .info span { 81 | color: #4d4d4d; 82 | font-size: 12px; 83 | } 84 | .container .info span a { 85 | color: #000000; 86 | text-decoration: none; 87 | } 88 | .container .info span .fa { 89 | color: #EF3B3A; 90 | } 91 | body { 92 | background: #76b852; /* fallback for old browsers */ 93 | background: -webkit-linear-gradient(right, #76b852, #8DC26F); 94 | background: -moz-linear-gradient(right, #76b852, #8DC26F); 95 | background: -o-linear-gradient(right, #76b852, #8DC26F); 96 | background: linear-gradient(to left, #76b852, #8DC26F); 97 | font-family: "Roboto", sans-serif; 98 | -webkit-font-smoothing: antialiased; 99 | -moz-osx-font-smoothing: grayscale; 100 | } -------------------------------------------------------------------------------- /html/assets/img/3rabutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/img/3rabutton.png -------------------------------------------------------------------------------- /html/assets/img/asc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/img/asc.gif -------------------------------------------------------------------------------- /html/assets/img/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/img/bg.gif -------------------------------------------------------------------------------- /html/assets/img/desc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/img/desc.gif -------------------------------------------------------------------------------- /html/assets/js/console.js: -------------------------------------------------------------------------------- 1 | var loc = window.location.pathname; 2 | var dir = loc.substring(0, loc.lastIndexOf('/')); 3 | var refreshtime=500; 4 | function tc_console() 5 | { 6 | asyncAjax("GET",dir + "/assets/api/console.php?d=" + server_select + "&s=console",Math.random(),display,{},"console"); 7 | asyncAjax("GET",dir + "/assets/api/console.php?d=" + server_select + "&s=chat",Math.random(),display,{},"chat"); 8 | setTimeout(function() { tc_console(); }, refreshtime ); 9 | } 10 | 11 | function display(xhr,cdat,scr) 12 | { 13 | if(xhr.readyState==4 && xhr.status==200) 14 | { 15 | var scrollContainer = document.getElementById(scr); 16 | var shouldScroll = scrollContainer.scrollTop + scrollContainer.offsetHeight >= scrollContainer.scrollHeight; 17 | scrollContainer.innerHTML=xhr.responseText; 18 | if(shouldScroll) { 19 | scrollContainer.scrollTop = scrollContainer.scrollHeight; 20 | } 21 | } 22 | } 23 | function asyncAjax(method,url,qs,callback,callbackData,scr) 24 | { 25 | var xmlhttp=new XMLHttpRequest(); 26 | //xmlhttp.cdat=callbackData; 27 | if(method=="GET") 28 | { 29 | url+="&t="+qs; 30 | } 31 | var cb=callback; 32 | callback=function() 33 | { 34 | var xhr=xmlhttp; 35 | //xhr.cdat=callbackData; 36 | var cdat2=callbackData; 37 | cb(xhr,cdat2,scr); 38 | return; 39 | }; 40 | xmlhttp.open(method,url,true); 41 | xmlhttp.onreadystatechange=callback; 42 | if(method=="POST"){ 43 | xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 44 | xmlhttp.send(qs); 45 | } 46 | else 47 | { 48 | xmlhttp.send(null); 49 | } 50 | } -------------------------------------------------------------------------------- /html/assets/js/cpumeminfo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by erkki on 26.1.2017. 3 | */ 4 | 5 | //quick and dirty cpu / mem updater 6 | $( document ).ready(function() { 7 | var cpulog = []; // array for future if multiple samples are needed. 8 | var delay = 2000; 9 | 10 | loop(); 11 | 12 | function loop(){ 13 | getData(); 14 | 15 | var data = cpulog[cpulog.length - 1]; 16 | 17 | if(data !== undefined) updateload(data); 18 | 19 | setInterval(() => { 20 | getData(); 21 | var data = cpulog[cpulog.length - 1]; 22 | if (data !== undefined) updateload(data); 23 | }, delay); 24 | } 25 | 26 | function updateload(data) { 27 | var cpuElem = $("#cpu"); 28 | var memElem = $("#mem"); 29 | 30 | var cpu = Math.round(100 - parseInt(data.cpu.idle)); 31 | var [usedMem, totalMem] = data.mem.split("/"); 32 | var memPercentage = (parseFloat(usedMem) / parseFloat(totalMem)).toFixed(2); 33 | 34 | cpuElem.text(cpu + " %"); 35 | cpuElem.css("background-color", getColor(cpu / 100)); 36 | 37 | memElem.text(data.mem + " GB"); 38 | memElem.css("background-color", getColor(memPercentage)); 39 | } 40 | 41 | function getColor(value){ 42 | //value from 0 to 1 43 | var hue=((1-value)*120).toString(10); 44 | return ["hsl(",hue,",100%,50%)"].join(""); 45 | } 46 | 47 | function getData() { 48 | $.ajax({ 49 | dataType: "json", 50 | url: "/assets/api/cpumeminfo.php" 51 | }).done(function(data) { 52 | if (cpulog.push(data) > 20) cpulog.shift(); 53 | }).fail(function() { 54 | console.error("error: cpumeminfo get fail."); 55 | }); 56 | } 57 | }); 58 | -------------------------------------------------------------------------------- /html/assets/js/customalerts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by erkki on 28.1.2017. 3 | */ 4 | 5 | /* 6 | * Js file must include bottom of the page it to work. 7 | * Alerts are stored to local storage so we won't lose everything every time page is loaded. 8 | * Example usage customAlerts.add("message","info",true); 9 | * or customAlerts.add("message").show(); 10 | * msg = msg, level: info, warning, error, show: nothing or true, will show modal. 11 | * level default: info, show: false 12 | * 13 | * Modal html. 14 | * 21 | */ 22 | 23 | var customAlerts = (function(){ 24 | var modal = document.getElementById('alert_modal'); 25 | var msg_log = []; 26 | var storage_size = 40; // amount of messages stored in localstorage. 27 | 28 | 29 | 30 | function show_modal(){ 31 | modal.style.display = "block"; 32 | } 33 | function hide_modal(){ 34 | modal.style.display = "none"; 35 | } 36 | function addMsgToModal(msg) { 37 | var date = new Date(msg.date); 38 | var messages = document.getElementById("messages"); 39 | messages.innerHTML = "
"+ 40 | "
"+msg.msg.replace(/(\r\n|\n|\r)/gm, "
")+"
"+ 41 | "
"+date.toLocaleString()+"
"+ 42 | "
" + messages.innerHTML; 43 | } 44 | 45 | document.getElementById("reset_alerts").onclick = function(){ 46 | msg_log = []; 47 | localStorage.removeItem("alert_messages"); 48 | document.getElementById("messages").innerHTML = ""; 49 | }; 50 | // modal close button 51 | document.getElementById("close_modal").onclick = function(){ 52 | hide_modal(); 53 | }; 54 | // Close modal when clicked outside the box 55 | window.onclick = function(event) { 56 | if (event.target == modal) { 57 | hide_modal(); 58 | } 59 | }; 60 | 61 | function save_messages(){ 62 | if (typeof(Storage) !== "undefined") { 63 | if(msg_log.length > storage_size){ 64 | msg_log = msg_log.slice((msg_log.length - storage_size),msg_log.length); 65 | } 66 | localStorage.setItem("alert_messages", JSON.stringify(msg_log)); 67 | } 68 | } 69 | 70 | function init(){ 71 | if (typeof(Storage) !== "undefined") { 72 | if(localStorage.getItem("alert_messages") !== null){ 73 | var messages = JSON.parse(localStorage.getItem("alert_messages")); 74 | messages.forEach(function(msg){ 75 | msg_log.push(msg); 76 | addMsgToModal(msg); 77 | }); 78 | } 79 | } 80 | msg_log.forEach(function(element) { 81 | addMsgToModal(element); 82 | }); 83 | } 84 | 85 | init(); 86 | 87 | return { 88 | // add nyw message. 89 | add: function (msg,level,show){ 90 | msg = (msg)? msg: ''; 91 | level = (level)? level:"info"; 92 | var message = {"msg": msg, "level": level, "date": Date.now()}; 93 | msg_log.push(message); 94 | addMsgToModal(message); 95 | save_messages(); 96 | if(show) show_modal(); 97 | return this; 98 | }, 99 | // show alert modal 100 | show: function(){ 101 | show_modal(); 102 | return this; 103 | }, 104 | // hide alert modal 105 | hide: function () { 106 | hide_modal(); 107 | return this; 108 | } 109 | } 110 | })(); 111 | 112 | // for testing. 113 | 114 | 115 | //customAlerts.add('test war ad asd asd asd asd a\n asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd asdasdasdasd asd \n ad asd asd asd asd a\n asd asd ad asd asd asd asd a\n asd asd asd \nasd \nasd asd asd \n ning','warning'); 116 | //customAlerts.add('test2 errro'); 117 | //customAlerts.add('test3 info' ,'info'); 118 | //customAlerts.add('test4 info' ,'warning'); 119 | //customAlerts.add('test5 error' ,'error'); 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /html/assets/modules/files_archive.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/files_archive.php -------------------------------------------------------------------------------- /html/assets/modules/files_delete.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/files_delete.php -------------------------------------------------------------------------------- /html/assets/modules/files_download.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/files_download.php -------------------------------------------------------------------------------- /html/assets/modules/files_upload.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/files_upload.php -------------------------------------------------------------------------------- /html/assets/modules/gameServer_forceKill.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/gameServer_forceKill.php -------------------------------------------------------------------------------- /html/assets/modules/gameServer_sendCommand.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/gameServer_sendCommand.php -------------------------------------------------------------------------------- /html/assets/modules/gameServer_start.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/gameServer_start.php -------------------------------------------------------------------------------- /html/assets/modules/gameServer_status.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/gameServer_status.php -------------------------------------------------------------------------------- /html/assets/modules/gameServer_stop.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/gameServer_stop.php -------------------------------------------------------------------------------- /html/assets/modules/logs_download.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/logs_download.php -------------------------------------------------------------------------------- /html/assets/modules/logs_list.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3RaGaming/Web_Control/6e440e1e1e6e536aeb9113ee7546c80fdcba185e/html/assets/modules/logs_list.php -------------------------------------------------------------------------------- /html/files.php: -------------------------------------------------------------------------------- 1 | $message]); 45 | exit(); 46 | } 47 | 48 | $upload_max_filesize_m = ini_get('upload_max_filesize'); 49 | $upload_max_filesize_b = return_bytes($upload_max_filesize_m); 50 | 51 | if(isset($_REQUEST['archive'])) { 52 | sendErrorResponse('this feature not ready yet.'); 53 | try 54 | { 55 | $a = new PharData('archive.tar'); 56 | 57 | // ADD FILES TO archive.tar FILE 58 | $a->addFile('data.xls'); 59 | $a->addFile('index.php'); 60 | 61 | // COMPRESS archive.tar FILE. COMPRESSED FILE WILL BE archive.tar.gz 62 | $a->compress(Phar::GZ); 63 | 64 | // NOTE THAT BOTH FILES WILL EXISTS. SO IF YOU WANT YOU CAN UNLINK archive.tar 65 | unlink('archive.tar'); 66 | } 67 | catch (Exception $e) 68 | { 69 | echo "Exception : " . $e; 70 | } 71 | die(); 72 | } elseif(isset($_REQUEST['download'])) { 73 | if($user_level=="viewonly") { 74 | sendErrorResponse('You have view only access.\nVisit our archive for file downloads\nwww.3ragaming.com/archive/factorio', 403); 75 | } 76 | if(empty($_REQUEST['download'])) 77 | { 78 | sendErrorResponse('empty download request'); 79 | } 80 | //file download requested. 81 | 82 | // file download found on http://www.media-division.com/php-download-script-with-resume-option/ 83 | // get the file request, throw error if nothing supplied 84 | 85 | // hide notices 86 | @ini_set('error_reporting', E_ALL & ~ E_NOTICE); 87 | 88 | //- turn off compression on the server 89 | // if apache 90 | // this seems to return true even when using nginx as the server 91 | //if(function_exists( apache_setenv )) { 92 | // @apache_setenv('no-gzip', 1); 93 | //} 94 | @ini_set('zlib.output_compression', 'Off'); 95 | 96 | // sanitize the file request, keep just the name and extension 97 | $file_path = $_REQUEST['download']; 98 | $path_parts = pathinfo($file_path); 99 | $file_name = $path_parts['basename']; 100 | $file_ext = $path_parts['extension']; 101 | $file_path = $base_dir . $server_select . "/saves/" . $file_name; 102 | // allow a file to be streamed instead of sent as an attachment 103 | $is_attachment = isset($_REQUEST['stream']) ? false : true; 104 | // make sure the file exists 105 | if (is_file($file_path)) 106 | { 107 | $file_size = filesize($file_path); 108 | $file = @fopen($file_path,"rb"); 109 | if ($file) 110 | { 111 | // set the headers, prevent caching 112 | header("Pragma: public"); 113 | header("Expires: -1"); 114 | header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0"); 115 | header("Content-Disposition: attachment; filename=\"$file_name\""); 116 | 117 | // set appropriate headers for attachment or streamed file 118 | if ($is_attachment) 119 | header("Content-Disposition: attachment; filename=\"$file_name\""); 120 | else 121 | header('Content-Disposition: inline;'); 122 | 123 | // set the mime type based on extension, add yours if needed. 124 | $ctype_default = "application/octet-stream"; 125 | $content_types = array( 126 | "exe" => "application/octet-stream", 127 | "zip" => "application/zip", 128 | "tar.gz" => "application/tar+gzip" 129 | ); 130 | $ctype = $content_types[$file_ext] ?? $ctype_default; 131 | header("Content-Type: " . $ctype); 132 | //check if http_range is sent by browser (or download manager) 133 | if(isset($_SERVER['HTTP_RANGE'])) { 134 | list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); 135 | if ($size_unit == 'bytes') { 136 | //multiple ranges could be specified at the same time, but for simplicity only serve the first range 137 | //http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt 138 | list($range, $extra_ranges) = explode(',', $range_orig, 2); 139 | } else { 140 | $range = ''; 141 | sendErrorResponse('Requested Range Not Satisfiable', 416); 142 | } 143 | } else { 144 | $range = ''; 145 | } 146 | //figure out download piece from range (if set) 147 | list($seek_start, $seek_end) = explode('-', $range, 2); 148 | 149 | //set start and end based on range (if set), else set defaults 150 | //also check for invalid ranges. 151 | $seek_end = (empty($seek_end)) ? ($file_size - 1) : min(abs(intval($seek_end)),($file_size - 1)); 152 | $seek_start = (empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)),0); 153 | 154 | //Only send partial content header if downloading a piece of the file (IE workaround) 155 | if ($seek_start > 0 || $seek_end < ($file_size - 1)) { 156 | header('HTTP/1.1 206 Partial Content'); 157 | header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$file_size); 158 | header('Content-Length: '.($seek_end - $seek_start + 1)); 159 | } else 160 | header("Content-Length: $file_size"); 161 | header('Accept-Ranges: bytes'); 162 | set_time_limit(0); 163 | fseek($file, $seek_start); 164 | while(!feof($file)) { 165 | print(@fread($file, 1024*8)); 166 | ob_flush(); 167 | flush(); 168 | // Check the connection status. If the connection has been aborted or the script timed out 169 | if (connection_status()!=0) { 170 | @fclose($file); 171 | sendErrorResponse('Connection was lost during file download.', 500); 172 | } 173 | } 174 | // file save was a success 175 | @fclose($file); 176 | exit(); 177 | } else { 178 | // file couldn't be opened 179 | sendErrorResponse('File could not be opened', 500); 180 | } 181 | } else { 182 | // file does not exist 183 | sendErrorResponse('File could not be found', 404); 184 | } 185 | /* END OF FILE DOWNLOAD */ 186 | //no reason to continue 187 | exit(); 188 | 189 | } elseif(isset($_REQUEST['upload'])) { 190 | if($user_level=="viewonly") { 191 | sendErrorResponse('You have read only access.' ,403); 192 | } else { 193 | //Valdidate name 194 | if(isset($_FILES['file']['name'])) { 195 | $filename = strtolower($_FILES['file']['name']); 196 | } else { 197 | sendErrorResponse('Error n'.__LINE__.': Invalid File'); 198 | } 199 | 200 | //Validate size 201 | if(isset($_FILES['file']['size'])) { 202 | if($_FILES['file']['size']<$upload_max_filesize_b) { 203 | $filesize = $_FILES['file']['size']; 204 | } else { 205 | sendErrorResponse("File must be less than $upload_max_filesize_m"); 206 | } 207 | } else { 208 | sendErrorResponse('Error s'.__LINE__.': Invalid File'); 209 | } 210 | 211 | if(isset($_FILES['file']['type'])) { 212 | $fileType = $_FILES['file']['type']; 213 | if( $fileType == "application/zip" || $fileType == "application/x-zip-compressed" || ($fileType == "application/octet-stream" && pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION) == "zip") ) { 214 | //we good 215 | } else { 216 | sendErrorResponse($fileType.'Invalid File Type'); 217 | } 218 | } else { 219 | sendErrorResponse('Error t'.__LINE__.': Invalid File'); 220 | } 221 | 222 | if(isset($_FILES['file']['tmp_name'])) { 223 | $fileTmp = $_FILES['file']['tmp_name']; 224 | $zip = new ZipArchive(); 225 | $res = $zip->open($fileTmp, ZipArchive::CHECKCONS); 226 | if ($res !== TRUE) { 227 | switch($res) { 228 | case ZipArchive::ER_NOZIP: 229 | unlink($fileTmp); 230 | sendErrorResponse('Error z'.__LINE__.': Not a zip archive'); 231 | /*case ZipArchive::ER_INCONS : 232 | unlink($fileTmp); 233 | sendErrorResponse('Error z'.__LINE__.': Zip consistency check failed');//*/ 234 | case ZipArchive::ER_CRC : 235 | unlink($fileTmp); 236 | sendErrorResponse('Error z'.__LINE__.': Zip checksum failed'); 237 | /*default: 238 | unlink($fileTmp); 239 | sendErrorResponse('Error z'.__LINE__.': Zip error ' . $res);//*/ 240 | } 241 | } 242 | } else { 243 | sendErrorResponse('Error t'.__LINE__.': Invalid File'); 244 | } 245 | 246 | $filename = preg_replace('/\s+/', '_', $filename); 247 | $full_file_path = $base_dir.$server_select."/saves/".$filename; 248 | ////This didn't work. The fopen stream was adding strange data to the file, which would corrupt the zip archive somehow. 249 | //$fh = fopen('php://input','r') or sendErrorResponse("Error opening the file"); 250 | //$blob = fgets($fh, 5); 251 | //if (strpos($blob, 'PK') !== false) { 252 | //looks like it is a zip file 253 | //} else { 254 | //fclose($fh); 255 | //sendErrorResponse( "invalid zip file" ); 256 | //} 257 | $file_users_path = "$base_dir$server_select/saves.json"; 258 | if(file_exists($file_users_path)) { 259 | $jsonString = file_get_contents($file_users_path); 260 | $file_list = json_decode($jsonString, true); 261 | $file_list_prehash = md5(serialize($file_list)); 262 | if(isset($file_list[$filename])) { 263 | $session['login']['reload_report']='File "'.$filename.'" was replaced'; 264 | } 265 | } 266 | $file_list[$filename] = $user_name; 267 | 268 | if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) { 269 | $move_uploaded_file = move_uploaded_file($fileTmp, $full_file_path); 270 | $file_list_prehash = null; 271 | if($move_uploaded_file == true) { 272 | $file_users_path = "$base_dir$server_select/saves.json"; 273 | if(file_exists($file_users_path)) { 274 | //Grab file list json and put into array 275 | $jsonString = file_get_contents($file_users_path); 276 | $file_list = json_decode($jsonString, true); 277 | //md5 hash to check if it changes 278 | $file_list_prehash = md5(serialize($file_list)); 279 | if(isset($file_list[$filename])) { 280 | $session['login']['reload_report']='File "'.$filename.'" was replaced'; 281 | } 282 | } 283 | $file_list[$filename] = $user_name; 284 | //if hash changes, a user over writ someones previous file, or a file has been added 285 | if($file_list_prehash !== md5(serialize($file_list))) { 286 | $newJsonString = json_encode($file_list, JSON_PRETTY_PRINT); 287 | file_put_contents($file_users_path, $newJsonString); 288 | } 289 | //does echo do anything here? 290 | echo "complete"; 291 | } else { 292 | $session['login']['reload_report']='Error u251: File failed to upload.'; 293 | } 294 | } else { 295 | $session['login']['reload_report']='Error u254: '.$_FILES["file"]["error"]; 296 | } 297 | if(isset($session['login']['reload_report'])) { 298 | if(!isset($_SESSION)) { session_start(); } 299 | $_SESSION['login']['reload_report'] = $session['login']['reload_report']; 300 | session_write_close(); 301 | } 302 | //$pre = file_put_contents($full_file_path, $fh); 303 | //fwrite($fh, $pre); 304 | //fclose($fh); 305 | } 306 | //no reason to carry on 307 | exit(); 308 | 309 | } elseif(isset($_REQUEST['delete'])) { 310 | if($user_level=="viewonly") { 311 | sendErrorResponse('You have view only access.', 403); 312 | } else { 313 | if(empty($_REQUEST['delete'])) 314 | { 315 | sendErrorResponse('No files selected for deletion'); 316 | } 317 | //2017-01-06-10:54:26.log 318 | $date = date('Y-m-d'); 319 | $time = date('H:i:s'); 320 | $delete_record = ""; 321 | $server_save_loc = "$base_dir$server_select/saves/"; 322 | $server_delete_loc = "$base_dir$server_select/logs/"; 323 | $server_delete_path = "$base_dir$server_select/logs/file_deletion-$date.log"; 324 | $file_users_path = "$base_dir$server_select/saves.json"; 325 | if(file_exists($server_save_loc)) { 326 | if(isset($_POST['delete'])) { 327 | //var_dump(json_decode($_POST['delete'])); 328 | $delete_array = json_decode($_POST['delete']); 329 | if ($delete_array == NULL || $delete_array === FALSE) { 330 | sendErrorResponse('Error p'.__LINE__.': invalid json in post'); 331 | } 332 | //set earlier $file_users_path 333 | if(file_exists($file_users_path)) { 334 | $jsonString = file_get_contents($file_users_path); 335 | $file_list = json_decode($jsonString, true); 336 | $file_list_prehash = md5(serialize($file_list)); 337 | } 338 | foreach($delete_array as $file) { 339 | if(file_exists($server_save_loc.$file)) { 340 | //echo "Will delete $server_save_loc$file\xA"; 341 | $tmp_file = $server_save_loc.$file; 342 | if(unlink($tmp_file)) { 343 | if(isset($file_list[$file])) { 344 | unset($file_list[$file]); 345 | } 346 | $delete_record = $delete_record ."$date-$time\t".$user_name."\t$file\xA"; 347 | } 348 | //log the delete and the user 349 | } 350 | } 351 | if($delete_record != "") { 352 | if (!is_dir($server_delete_loc)) { 353 | // dir doesn't exist, make it 354 | mkdir($server_delete_loc); 355 | } 356 | file_put_contents($server_delete_path, $delete_record, FILE_APPEND); 357 | if(isset($file_list) && $file_list_prehash !== md5(serialize($file_list))) { 358 | $newJsonString = json_encode($file_list, JSON_PRETTY_PRINT); 359 | file_put_contents($file_users_path, $newJsonString); 360 | } 361 | } 362 | $session['login']['reload_report'] = "Files Deleted"; 363 | if(isset($session['login']['reload_report'])) { 364 | session_start(); 365 | $_SESSION['login']['reload_report'] = $session['login']['reload_report']; 366 | session_write_close(); 367 | } 368 | sendErrorResponse('success', 200); 369 | } else { 370 | sendErrorResponse('Error p'.__LINE__.': with post information.'); 371 | } 372 | } else { 373 | sendErrorResponse('Error p'.__LINE__.': in server path'); 374 | } 375 | } 376 | //no reason to carry on 377 | exit(); 378 | 379 | } else { 380 | sendErrorResponse('Error u'.__LINE__.': No action requested'); 381 | } 382 | -------------------------------------------------------------------------------- /html/getserver.php: -------------------------------------------------------------------------------- 1 | '.$dir.'\'); 45 | $("#server_list").append(\'
\');'; 46 | } 47 | } 48 | $server_tab_list = $server_tab_list . " 49 | "; 50 | -------------------------------------------------------------------------------- /html/index.php: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 27 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 |
115 |
116 | Welcome, ..guest.. -  117 |     118 |  -  119 |  -  120 |  -  121 | config -  122 | 123 | 124 | 127 | 128 | Logs 129 |
130 |  -  131 | Logout 132 |
133 |
134 | 00 % 135 | 0.00/0.00 GB 136 |
137 | 138 | 139 | 140 |
141 | 142 |
143 | 144 |
145 |   146 | 147 |
148 | 149 |
150 |
151 | 152 | 153 | 154 | 155 |  :  156 |  :  157 | 158 | 159 | 160 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 |
FileSizeCreationOriginator
175 | 176 |
177 |
178 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /html/login.php: -------------------------------------------------------------------------------- 1 | $url, 59 | CURLOPT_RETURNTRANSFER => 1, 60 | CURLOPT_FOLLOWLOCATION => 1, 61 | CURLOPT_POST => true, 62 | CURLOPT_POSTFIELDS => $postField ); 63 | 64 | $curlrqst0 = curl_init(); 65 | curl_setopt_array($curlrqst0, $options); 66 | $tokenobject = curl_exec($curlrqst0); 67 | $tokenjson = json_decode($tokenobject, true); 68 | 69 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." tokenJson"] = array(print_r($tokenjson, true), curl_error($curlrqst0)); } 70 | 71 | curl_close($curlrqst0); 72 | 73 | if(isset($tokenjson['access_token'])) { 74 | $token = $tokenjson['access_token']; 75 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." Token Set"] = true; } 76 | } else { 77 | $error = "access_token"; 78 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." Token *NOT* Set"] = false; } 79 | } 80 | if(!isset($error)) { 81 | $tokenheader = array(); 82 | $tokenheader[] = 'Content-Type application/json'; 83 | $tokenheader[] = 'Authorization: Bearer '.$token; 84 | 85 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." token header"] = print_r($tokenheader, true); } 86 | 87 | $curlrqst1 = curl_init('https://discordapp.com/api/users/@me'); 88 | curl_setopt($curlrqst1, CURLOPT_HTTPHEADER, $tokenheader); 89 | curl_setopt($curlrqst1, CURLOPT_RETURNTRANSFER, true); 90 | $userobject = curl_exec($curlrqst1); 91 | $userjson = json_decode($userobject, true); 92 | 93 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." UserJson"] = array(print_r($userjson, true), curl_error($curlrqst1)); } 94 | 95 | curl_close($curlrqst1); 96 | 97 | if(isset($userjson["id"])) { 98 | $userid = $userjson["id"]; 99 | } else { 100 | $error = "user_json_id"; 101 | } 102 | 103 | $curlrqst2 = curl_init('https://discordapp.com/api/guilds/'.$guildid.'/members/'.$userid); 104 | curl_setopt($curlrqst2, CURLOPT_HTTPHEADER, $botheader); 105 | curl_setopt($curlrqst2, CURLOPT_RETURNTRANSFER, true); 106 | $memberobject = curl_exec($curlrqst2); 107 | $memberjson = json_decode($memberobject, true); 108 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." MemberJson"] = array(print_r($memberjson, true), curl_error($curlrqst2)); } 109 | curl_close($curlrqst2); 110 | if (isset($memberjson['code'])&&($memberjson['code']==10007)) { 111 | $error = "member_no_exist"; 112 | } elseif(!isset($memberjson["user"]["username"]) || !isset($memberjson["roles"])) { 113 | $error = "member_data_invalid"; 114 | } 115 | 116 | if(!isset($error)) { 117 | $curlrqst3 = curl_init('https://discordapp.com/api/guilds/'.$guildid.'/roles'); 118 | curl_setopt($curlrqst3, CURLOPT_HTTPHEADER, $botheader); 119 | curl_setopt($curlrqst3, CURLOPT_RETURNTRANSFER, true); 120 | $roleobject = curl_exec($curlrqst3); 121 | $rolejson = json_decode($roleobject, true); 122 | 123 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." RolesJson"] = array(print_r($rolejson, true), curl_error($curlrqst3)); } 124 | 125 | curl_close($curlrqst3); 126 | 127 | $level1id = null; 128 | $level2id = null; 129 | foreach($rolejson as $key => $value) { 130 | if($rolejson[$key]["name"] == $level1role) $level1id = $rolejson[$key]["id"]; 131 | if($rolejson[$key]["name"] == $level2role) $level2id = $rolejson[$key]["id"]; 132 | if($level1id !== null && $level2id !== null) break 1; 133 | } 134 | 135 | $level1 = false; 136 | $level2 = false; 137 | if(isset($memberjson["roles"])) { 138 | foreach($memberjson["roles"] as $mkey => $mvalue) { 139 | if($mvalue == $level1id) $level1 = true; 140 | if($mvalue == $level2id) $level2 = true; 141 | if($level1 && $level2) break 1; 142 | } 143 | } 144 | 145 | if ($level1 || $userid == "129357924324605952" /* zacks id */) { 146 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." admin login verified!"] = true; } 147 | $session['login']['user']=$memberjson["user"]["username"]; 148 | $session['login']['level']="admin"; 149 | } elseif ($level2) { 150 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." mod login verified!"] = true; } 151 | $session['login']['user']=$memberjson["user"]["username"]; 152 | $session['login']['level']="mod"; 153 | } elseif($userid == "264805254758006801" ) { 154 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." guest only assigned!"] = true; } 155 | $session['login']['user']=$memberjson["user"]["username"]; 156 | $session['login']['level']="guest"; 157 | } else { 158 | /* DEBUG */if(isset($debug)) { $debugArr[][__LINE__." unauthorized user!"] = false; } 159 | $error = "unauthorized"; 160 | } 161 | } 162 | } 163 | } 164 | } /* DEBUG */elseif(isset($debug)) { 165 | $debugArr[][__LINE__." No CODE parameter found."] = false; 166 | } 167 | 168 | /**** Alternate Login Processing Below ****/ 169 | $userN=""; 170 | $passW=""; 171 | if(isset($_POST['uname'])) { 172 | $userN = addslashes($_POST['uname']); 173 | } 174 | if(isset($_POST['passw'])) { 175 | $passW = addslashes(md5(trim($_POST['passw']))); 176 | } 177 | if(isset($_POST['submit'])) { 178 | /* DEBUG */ if(isset($debug)) { 179 | $debugArr[][__LINE__." Alt-login post data submitted"] = "username:'$userN' - password:'$passW'"; 180 | } 181 | } 182 | if(!empty($userN) && !empty($passW)) { 183 | $userlist = file ('/var/www/users.txt'); 184 | $success = false; 185 | foreach ($userlist as $user) { 186 | $user_details = explode('|', $user); 187 | if ((strtolower($user_details[0]) == strtolower($userN)) && trim($user_details[1]) == $passW) { 188 | $userN = $user_details[0]; 189 | $userL = $user_details[2]; 190 | $success = true; 191 | break; 192 | } 193 | } 194 | if ($success) { 195 | if($debug) { 196 | $report = "With debug disabled, Session would have been created."; 197 | $debugArr[][__LINE__." Login would-be success"] = print_r($session, true); 198 | } else { 199 | $session['login']['user']=$userN; 200 | $session['login']['level']=trim($userL); 201 | //Allow login 202 | } 203 | } else { 204 | $error = "password"; 205 | } 206 | } elseif(isset($_POST['submit'])) { 207 | $error = "form_empty"; 208 | } 209 | /**** Handle Error Messages ****/ 210 | if(isset($error)) { 211 | switch($error) { 212 | case "unauthorized": 213 | $report = "You are not authorized to access this page"; 214 | break; 215 | case "access": 216 | $report = "You must agree to provide access to your account"; 217 | break; 218 | case "access_token": 219 | $report = "Error with discord API"; 220 | break; 221 | case "member": 222 | $report = "You are not a member of the Discord Server"; 223 | break; 224 | case "logged_out": 225 | $report = "You have been logged out"; 226 | break; 227 | case "logged_in": 228 | $report = "You are already logged in"; 229 | break; 230 | case "password"; 231 | $report = "Invalid username or password"; 232 | break; 233 | case "form_empty"; 234 | $report = "
I don't like no input
"; 235 | break; 236 | default: 237 | $report = "Unknown Error Occurred - $error"; 238 | } 239 | } elseif(isset($session['login']['user'])&&isset($session['login']['level'])) { 240 | if(isset($debug)) { 241 | $report = "With debug disabled, Session would have been created."; 242 | $debug[] = print_r($session, true); 243 | } else { 244 | if(session_status()!=2) { session_start(); } 245 | $_SESSION['login']['user'] = $session['login']['user']; 246 | $_SESSION['login']['level'] = $session['login']['level']; 247 | header("Location: ./index.php?d=server1"); 248 | die(); 249 | } 250 | } 251 | $config_file = file_get_contents('/var/www/factorio/config.json'); 252 | $json_config = json_decode($config_file, true); 253 | $clientid = $json_config['clientid']; 254 | /* DEBUG */ if(isset($debug)) { 255 | if(( isset($clientid) && $clientid == "PUT_YOUR_BOT_CLIENT_ID_HERE" )) { 256 | $debugArr[][__LINE__." Default clientid"] = "Default JSON['clientid'] being used. Discord Auth unavailable."; 257 | } 258 | } 259 | ?> 260 | 261 | 262 | 263 | 264 | 280 | 281 | 282 | 303 | 304 | "; 307 | print_r($debug); 308 | echo ""; 309 | } 310 | ?> 311 | 312 | -------------------------------------------------------------------------------- /html/logs.php: -------------------------------------------------------------------------------- 1 | $value - $size - $date
"; 51 | } 52 | } 53 | $full_dir = $server_dir . "logs"; 54 | foreach(array_diff(scandir("$full_dir"), array('..', '.')) as $file) { 55 | $file_full_path = "$full_dir/$file"; 56 | $size = human_filesize("$file_full_path"); 57 | $date = date ("Y-m.M-d H:i:s", filemtime("$file_full_path")); 58 | echo " $file - $size - $date
"; 59 | } 60 | die(); 61 | } 62 | } 63 | if(isset($_REQUEST['download'])&&isset($_REQUEST['d'])) { 64 | $server_select = $server_select ?? "failed"; 65 | $server_dir = $base_dir . $server_select . "/"; 66 | if(isset($_REQUEST['d'])) { 67 | if($_REQUEST['d']=="Managepgm") { 68 | $server_select="Managepgm"; 69 | $server_dir = $base_dir; 70 | } elseif($_REQUEST['d']!==$server_select||$server_select=="failed") { 71 | die('Error in check'); 72 | } 73 | } 74 | //Current running log file, or archived log file? 75 | if($_REQUEST['download']=="screenlog.0"||$_REQUEST['download']=="factorio-current.log") { 76 | //um... how can this be done better? 77 | } else { 78 | $server_dir = $server_dir . "logs/"; 79 | } 80 | if(file_exists($server_dir)) { 81 | $file_path = $server_dir . $_REQUEST['download']; 82 | if(file_exists($file_path)) { 83 | if($user_level=="viewonly") { 84 | die('You have read only access.\nVisit our archive for file downloads\nwww.3ragaming.com/archive/factorio'); 85 | } 86 | // file download found on http://www.media-division.com/php-download-script-with-resume-option/ 87 | // get the file request, throw error if nothing supplied 88 | 89 | // hide notices 90 | @ini_set('error_reporting', E_ALL & ~ E_NOTICE); 91 | 92 | //- turn off compression on the server 93 | if(function_exists( 'apache_setenv')) { 94 | @apache_setenv('no-gzip', 1); 95 | } 96 | @ini_set('zlib.output_compression', 'Off'); 97 | 98 | // sanitize the file request, keep just the name and extension 99 | // also, replaces the file location with a preset one ('./myfiles/' in this example) 100 | $path_parts = pathinfo($file_path); 101 | $file_name = $path_parts['filename']; 102 | $file_ext = $path_parts['extension']; 103 | // allow a file to be streamed instead of sent as an attachment 104 | $is_attachment = isset($_REQUEST['stream']) ? false : true; 105 | // make sure the file exists 106 | if (is_file($file_path)) 107 | { 108 | $file_size = filesize($file_path); 109 | $file = @fopen($file_path,"rb"); 110 | if ($file) 111 | { 112 | // set the headers, prevent caching 113 | header("Pragma: public"); 114 | header("Expires: -1"); 115 | header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0"); 116 | header("Content-Disposition: attachment; filename=\"$server_select-$file_name.$file_ext\""); 117 | 118 | // set appropriate headers for attachment or streamed file 119 | if ($is_attachment) { 120 | header("Content-Disposition: attachment; filename=\"$server_select-$file_name.$file_ext\""); 121 | } else { 122 | header('Content-Disposition: inline;'); 123 | } 124 | 125 | header("Content-Type: text/plain"); 126 | //check if http_range is sent by browser (or download manager) 127 | if(isset($_SERVER['HTTP_RANGE'])) { 128 | list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); 129 | if ($size_unit == 'bytes') { 130 | //multiple ranges could be specified at the same time, but for simplicity only serve the first range 131 | //http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt 132 | list($range, $extra_ranges) = explode(',', $range_orig, 2); 133 | } else { 134 | $range = ''; 135 | header('HTTP/1.1 416 Requested Range Not Satisfiable'); 136 | exit; 137 | } 138 | } else { 139 | $range = ''; 140 | } 141 | //figure out download piece from range (if set) 142 | list($seek_start, $seek_end) = explode('-', $range, 2); 143 | 144 | //set start and end based on range (if set), else set defaults 145 | //also check for invalid ranges. 146 | $seek_end = (empty($seek_end)) ? ($file_size - 1) : min(abs(intval($seek_end)),($file_size - 1)); 147 | $seek_start = (empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)),0); 148 | 149 | //Only send partial content header if downloading a piece of the file (IE workaround) 150 | if ($seek_start > 0 || $seek_end < ($file_size - 1)) { 151 | header('HTTP/1.1 206 Partial Content'); 152 | header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$file_size); 153 | header('Content-Length: '.($seek_end - $seek_start + 1)); 154 | } else 155 | header("Content-Length: $file_size"); 156 | header('Accept-Ranges: bytes'); 157 | set_time_limit(0); 158 | fseek($file, $seek_start); 159 | while(!feof($file)) { 160 | print(@fread($file, 1024*8)); 161 | ob_flush(); 162 | flush(); 163 | if (connection_status()!=0) { 164 | @fclose($file); 165 | exit; 166 | } 167 | } 168 | // file save was a success 169 | @fclose($file); 170 | exit; 171 | } else { 172 | // file couldn't be opened 173 | header("HTTP/1.0 500 Internal Server Error"); 174 | exit; 175 | } 176 | } else { 177 | // file does not exist 178 | header("HTTP/1.0 404 Not Found"); 179 | die('dead'); 180 | exit; 181 | } 182 | /* END OF FILE DOWNLOAD */ 183 | //no reason to continue 184 | die(); 185 | } else { 186 | echo "NOT exists $file_path $server_select"; 187 | die(); 188 | } 189 | } 190 | die(); 191 | } 192 | } 193 | ?> 194 | 195 | 196 | 197 | 198 | 231 | 232 | 233 | 234 | 235 |
236 |
237 | Welcome, ..guest.. -  238 | Home -  239 | Config -  240 | Logs   241 | 242 |
243 | Logout 244 |
245 |
246 | 247 |
248 |
249 | 252 |
Dynamic tab for Managepgm
253 |
254 | 255 |
256 |
257 | 258 | 259 | 25) { 130 | array_pop($_SESSION['login']['cmd_history'][$server_select]); 131 | } 132 | } else { 133 | $_SESSION['login']['cmd_history'][$server_select] = array($cmd_history); 134 | } 135 | session_write_close(); 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /html/server-settings.php: -------------------------------------------------------------------------------- 1 | "; 76 | echo ""; 77 | echo ""; 78 | foreach($server_settings as $key => $value) { 79 | if(strpos($key, '_comment') === false && !in_array($key, $disabled)) { 80 | if(in_array($key, $doublespan)) { 81 | echo ""; 110 | echo ""; 146 | } 147 | } 148 | echo "
"; 82 | $col = ""; 83 | } else { 84 | echo "
"; 85 | $col = ""; 86 | } 87 | $display = str_replace($replace_this, $replace_with_that, $key); 88 | if(is_string($value)||is_int($value)) { 89 | if($key=="allow_commands") { 90 | if($value=="true") { 91 | echo "$display:$col"; 92 | } elseif($value=="false") { 93 | echo "$display:$col"; 94 | } else { 95 | echo "$display:$col"; 96 | } 97 | } else { 98 | //ghetto way to add version selection to this page 99 | if($key == "max_players") { 100 | echo "Server Version:$col Version Manager"; 109 | echo "
"; 111 | } 112 | echo "$display:$col
"; 113 | } 114 | } elseif(is_array($value)) { 115 | if($key == "visibility") { 116 | echo "$display:$col"; 117 | foreach($value as $sub_key => $sub_value) { 118 | if($sub_value=="true") { 119 | echo "$sub_key: "; 120 | } else { 121 | echo "$sub_key: "; 122 | } 123 | } 124 | echo "
"; 125 | } else { 126 | echo "$display:$col"; 127 | $sub_value = ""; 128 | if($value!="") { 129 | $sub_value = implode(", ", $value); 130 | } 131 | echo " "; 132 | echo "
"; 133 | } 134 | } elseif(is_bool($value)) { 135 | if($value==true) { 136 | echo "$display:$col
"; 137 | } else { 138 | echo "$display:$col
"; 139 | } 140 | } else { 141 | echo "$key:$col"; 142 | var_dump($value); 143 | echo "
"; 144 | } 145 | echo "
"; 149 | echo ""; 150 | echo ""; 151 | echo "
"; 152 | //echo "
";
153 | 					//echo json_encode($server_settings, JSON_PRETTY_PRINT);
154 | 					//echo "
"; 155 | } 156 | } 157 | die(); 158 | } elseif(isset($_REQUEST['server_select'])) { 159 | $verified_data = []; 160 | $err_data["error"] = true; 161 | $err = 0; 162 | $total_array = array(); 163 | $ignore_array = array("d","server_select"); 164 | $settype_string = array("name","description","game_password","allow_commands"); 165 | $settype_integers = array("max_players","max_upload_in_kilobytes_per_second","autosave_interval","autosave_slots","afk_autokick_interval","minimum_latency_in_ticks"); 166 | $settype_boolean = array("visibility-public","visibility-lan","require_user_verification","ignore_player_limit_for_returning_players","auto_pause","only_admins_can_pause_the_game","autosave_only_on_server","non_blocking_saving"); 167 | $settype_array = array("tags","admins"); 168 | $check_array_admin = array("true","false","admins-only"); 169 | foreach($_REQUEST as $key => $value) { 170 | $clean_key = preg_replace('/[^\da-z]_/i', '', $key); 171 | $clean_value = preg_replace(array("/\/", "/\s+/"), array("", "", " "), $value); 172 | if(in_array($clean_key, $settype_string) || ($clean_key == "allow_commands" && in_array($clean_value, $check_array_admin))) { 173 | $verified_data[$clean_key] = $clean_value; 174 | continue; 175 | } elseif(in_array($clean_key, $settype_integers)) { 176 | if(is_numeric($clean_value)) { 177 | settype($clean_value, "integer"); 178 | $verified_data[$clean_key] = $clean_value; 179 | } else { 180 | $err_data[$clean_key]=$clean_value; 181 | $err++; 182 | } 183 | continue; 184 | } elseif(in_array($clean_key, $settype_array)) { 185 | //work this 186 | $raw_array = explode(',', $clean_value); 187 | $trimmed_array=array_map('trim',$raw_array); 188 | $verified_data[$clean_key] = $trimmed_array; 189 | continue; 190 | } elseif(in_array($clean_key, $settype_boolean)) { 191 | if($clean_value == "true") { 192 | $clean_value = true; 193 | } elseif($clean_value == "false") { 194 | $clean_value = false; 195 | } else { 196 | $err_data[$clean_key]=$clean_value; 197 | $err++; 198 | continue; 199 | } 200 | if($clean_key == "visibility-public" || $clean_key == "visibility-lan") { 201 | $raw_value = explode('-', $clean_key); 202 | $verified_data["visibility"][$raw_value[1]] = $clean_value; 203 | } else { 204 | $verified_data[$clean_key] = $clean_value; 205 | } 206 | continue; 207 | } elseif(!in_array($clean_key, $ignore_array)) { 208 | if($clean_key == "s_version") { 209 | $s_version = $clean_value; 210 | continue; 211 | } 212 | $err_data[$clean_key]=$clean_value; 213 | $err++; 214 | continue; 215 | } 216 | } 217 | 218 | if(isset($err) && $err > 0) { 219 | echo json_encode($err_data, JSON_PRETTY_PRINT); 220 | } else { 221 | $date = date('Y-m-d'); 222 | $time = date('H:i:s'); 223 | $server_dir = $base_dir . $server_select . "/"; 224 | $server_config_path = $server_dir . "config/config.ini"; 225 | $server_settings_path = $server_dir . "server-settings.json"; 226 | $server_settings_web_path = $server_dir . "server-settings-web.json"; 227 | $server_settings_run_path = $server_dir . "running-server-settings.json"; 228 | $server_log_loc = $server_dir . "logs/"; 229 | $server_log_path = $server_dir . "logs/server-settings-update-$date.log"; 230 | 231 | if(isset($s_version)) { 232 | if(isset($server_installed_versions[$s_version])) { 233 | $server_settings_web['version']=$s_version; 234 | $newJsonString = json_encode($server_settings_web, JSON_PRETTY_PRINT); 235 | file_put_contents($server_settings_web_path, $newJsonString); 236 | //also want to update the config.ini file 237 | if(file_exists($server_config_path)) { 238 | $lines = file($server_config_path); 239 | $new_config = array(); 240 | foreach($lines as $line) { 241 | if(substr($line, 0, 10) == 'read-data=') { 242 | $new_config[] = "read-data=".$server_installed_versions[$s_version]."/data\n"; 243 | } else { 244 | $new_config[] = $line; 245 | } 246 | } 247 | file_put_contents($server_config_path, $new_config); 248 | } 249 | } 250 | } 251 | if(file_exists($server_settings_path)) { 252 | $server_settings = json_decode(file_get_contents("$base_dir$server_select/server-settings.json"), true); 253 | foreach($verified_data as $key => $value) { 254 | $server_settings[$key] = $verified_data[$key]; 255 | } 256 | $newJsonString = json_encode($server_settings, JSON_PRETTY_PRINT); 257 | $newJsonStringUgly = json_encode($server_settings); 258 | $newRawQuery = http_build_query($_REQUEST); 259 | $log_record = "\xA$date-$time\t".$user_name."\xA$newJsonStringUgly\xA$newRawQuery\xA"; 260 | if($log_record != "") { 261 | if (!is_dir($server_log_loc)) { 262 | // dir doesn't exist, make it 263 | mkdir($server_log_loc); 264 | } 265 | file_put_contents($server_log_path, $log_record, FILE_APPEND); 266 | } 267 | file_put_contents($server_settings_path, $newJsonString); 268 | $output = json_encode("Settings Updated"); 269 | die($output); 270 | } else { 271 | $output = json_encode("No settings file found"); 272 | die($output); 273 | } 274 | } 275 | die(); 276 | } 277 | } 278 | ?> 279 | 280 | 281 | 282 | 396 | 397 | 398 | 399 | 400 | 401 |
402 |
403 | Welcome, ..guest.. -  404 | Home -  405 | Config -  406 | Logs 407 | 408 | 409 |
410 | Logout 411 |
412 |
413 | 414 |
415 |
416 |
    417 |
418 |
419 |
420 |
421 | 422 | 423 | "; 16 | if($_POST['update']=="yes") { 17 | echo "
Updating...\r\n";
18 | 				ob_flush();
19 | 				flush();
20 | 				//retrieve $count to know how mant times to loop later
21 | 				exec('bash update.sh count', $count);
22 | 				ob_flush();
23 | 				flush();
24 | 				//we loop here so we can flush the output and view the update progress in the web control.
25 | 				for($n=1; $n<=$count[0]; $n++) {
26 | 					system('bash update.sh '.$n.'');
27 | 					ob_flush();
28 | 					flush();
29 | 				}
30 | 				echo "Done\r\n
\r\n\r\n"; 31 | echo ""; 32 | ob_flush(); 33 | flush(); 34 | } 35 | } else { 36 | header("Location: ./login.php?POSTnotset"); 37 | die(); 38 | } 39 | } else { 40 | header("Location: ./login.php?notadmin"); 41 | die(); 42 | } 43 | -------------------------------------------------------------------------------- /html/version_manager.php: -------------------------------------------------------------------------------- 1 | "install", "username" => $user_name, "time" => $GLOBALS['date'] ." ". $GLOBALS['time']), JSON_PRETTY_PRINT)); 89 | if(is_dir($program_dir)) { 90 | unlink($tmp_file); 91 | return "Install failed. Directory exists."; 92 | } else { 93 | $url = "https://www.factorio.com/download/archive/"; 94 | //run this script on each url in the array until a match is found 95 | $server_matched_versions = get_url($url); 96 | //if a download link is found, iterate the results 97 | if(isset($server_matched_versions[1])) { 98 | foreach($server_matched_versions[1] as $key => $value) { 99 | $direct_url = "https://factorio.com/get-download/$version/headless/linux64"; 100 | } 101 | } 102 | if(isset($direct_url)) { 103 | //create status files periodically so other users know whats going on. Should be able to use this for active user status updates as well 104 | file_put_contents($tmp_file, json_encode(array("action" => "downloading", "username" => $user_name, "time" => $GLOBALS['date'] ." ". $GLOBALS['time']), JSON_PRETTY_PRINT)); 105 | //get's filename and download url, actually... 106 | $file = getFilename($direct_url); 107 | //make sure we get both in return 108 | if(isset($file[0])&&isset($file[1])) { 109 | //define the function so we can get download status as we download 110 | function progressCallback( $resource, $download_size, $downloaded_size, $upload_size, $uploaded_size ) 111 | { 112 | global $progress_file; 113 | static $previousProgress = 0; 114 | if ( $download_size == 0 ) 115 | $progress = 0; 116 | else 117 | $progress = round( $downloaded_size * 100 / $download_size ); 118 | if ( $progress > $previousProgress) 119 | { 120 | $previousProgress = $progress; 121 | //this *should* replace the file contents on each update. ajax can check for updates for a pretty progress bar and/or percentage 122 | file_put_contents( $progress_file, "$progress" ); 123 | } 124 | } 125 | //clean up the URL, filename and set the temporary path 126 | $url = $file[0]; 127 | $filename_loc = "/tmp/".$file[1]; 128 | file_put_contents( $progress_file, '0' ); 129 | $targetFile = fopen( $filename_loc, 'w' ); 130 | $ch = curl_init(); 131 | curl_setopt($ch, CURLOPT_URL, $url); 132 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 133 | curl_setopt($ch, CURLOPT_HEADER, false); 134 | curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 135 | curl_setopt($ch, CURLOPT_NOPROGRESS, false ); 136 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 137 | curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' ); 138 | curl_setopt($ch, CURLOPT_FILE, $targetFile ); 139 | $result = curl_exec($ch); 140 | curl_close($ch); 141 | fclose( $targetFile ); 142 | if($result === false) 143 | { 144 | return 'Curl error: ' . __LINE__ . ' ' . curl_error($ch); 145 | } //continue if successful 146 | unlink($progress_file); 147 | file_put_contents($tmp_file, json_encode(array("action" => "unpacking", "username" => $user_name, "time" => $GLOBALS['date'] ." ". $GLOBALS['time']), JSON_PRETTY_PRINT)); 148 | if(is_dir($program_dir)) { 149 | return "directory exists"; 150 | } else { 151 | $fileType = mime_content_type($filename_loc); 152 | switch ($fileType) { 153 | case "application/x-xz": 154 | //unlink($filename_loc); 155 | //return "filetype not yet implemented: $fileType"; 156 | $tar_dir = "/tmp/$version/"; 157 | if(is_dir($tar_dir)) { 158 | rrmdir($tar_dir); 159 | } 160 | mkdir($tar_dir); 161 | exec("tar -xf $filename_loc -C $tar_dir"); 162 | function is_dir_empty($dir) { 163 | if (!is_readable($dir)) return NULL; 164 | $handle = opendir($dir); 165 | while (false !== ($entry = readdir($handle))) { 166 | if ($entry != "." && $entry != "..") { 167 | return FALSE; 168 | } 169 | } 170 | return TRUE; 171 | } 172 | unlink($filename_loc); 173 | if(is_dir_empty($tar_dir)) { 174 | return "install fail. 'tar_dir' is empty $tar_dir"; 175 | } else { 176 | $files_dir = $tar_dir."factorio"; 177 | move_dir($files_dir, $program_dir); 178 | rrmdir($tar_dir); 179 | if(is_dir_empty($program_dir)) { 180 | return "failed to move from tmp to $program_dir"; 181 | } else { 182 | return "Install Successfull! $program_dir"; 183 | } 184 | } 185 | break; 186 | case "application/x-gzip"; 187 | $filename_tar = pathinfo( $filename_loc, PATHINFO_FILENAME ).".tar"; 188 | $filepath_tar = "/tmp/$filename_tar"; 189 | if(file_exists($filepath_tar)) { 190 | unlink($filepath_tar); 191 | } 192 | $p = new PharData($filename_loc); 193 | $p->decompress(); // creates /path/to/my.tar 194 | unlink($filename_loc); 195 | $i = 0; 196 | while ( $i < 8 ) { 197 | if(!file_exists($filepath_tar)) { 198 | usleep(250000); 199 | } else { 200 | $i=10; 201 | } 202 | $i++; 203 | } 204 | if(!file_exists($filepath_tar)) { 205 | return "unable to make tar file"; 206 | } 207 | // unarchive from the tar 208 | try { 209 | $phar = new PharData($filepath_tar); 210 | $tar_dir = "/tmp/$version/"; 211 | //mkdir($tar_dir); 212 | $phar->extractTo($tar_dir); 213 | } catch (Exception $e) { 214 | unlink($filepath_tar); 215 | if(is_dir($tar_dir)) rrmdir($tar_dir); 216 | return "tar extract failure: $e"; 217 | // handle errors 218 | } 219 | function is_dir_empty($dir) { 220 | if (!is_readable($dir)) return NULL; 221 | $handle = opendir($dir); 222 | while (false !== ($entry = readdir($handle))) { 223 | if ($entry != "." && $entry != "..") { 224 | return FALSE; 225 | } 226 | } 227 | return TRUE; 228 | } 229 | unlink($filepath_tar); 230 | if(is_dir_empty($tar_dir)) { 231 | return "install fail. Dir is empty"; 232 | } else { 233 | $files_dir = $tar_dir."factorio"; 234 | move_dir($files_dir, $program_dir); 235 | rmdir($tar_dir); 236 | if(is_dir_empty($program_dir)) { 237 | return "failed to move from tmp to $program_dir"; 238 | } else { 239 | return "success"; 240 | } 241 | } 242 | break; 243 | default: 244 | return "unsupported filetyle: $fileType"; 245 | } 246 | } 247 | } else { 248 | return "issue finding remote file ".$file[0]." ".$file[1]; 249 | } 250 | } else { 251 | return "no download found"; 252 | } 253 | } 254 | } 255 | function delete($version, $program_dir, $tmp_file) { 256 | file_put_contents($tmp_file, json_encode(array("action" => "deleting", "username" => $user_name, "time" => $GLOBALS['date'] ." ". $GLOBALS['time']), JSON_PRETTY_PRINT)); 257 | rrmdir($program_dir); 258 | if(is_dir($program_dir)) { 259 | unlink($tmp_file); 260 | return "delete failed"; 261 | } else { 262 | unlink($tmp_file); 263 | return "success"; 264 | } 265 | } 266 | $log_dir = "/var/www/factorio/logs"; 267 | $log_path = "$log_dir/version-manager-".$GLOBALS['date'].".log"; 268 | if(isset($_REQUEST)) { 269 | if(isset($_REQUEST['status'])&&$_REQUEST['status']!="") { 270 | if( $user_level == "viewonly" ) { 271 | die('View-only may not manage versions'); 272 | } 273 | if($_REQUEST['status']!="") { 274 | $js_value = preg_replace('/_/', '.', $_REQUEST['status']); 275 | $version = preg_replace('/[^0-9.]+/', '', $js_value); 276 | $tmp_file = "/tmp/factorio-version-manager_progress.$version.txt"; 277 | //factorio-version-manager_progress.0.12.35.txt 278 | if(file_exists($tmp_file)) { 279 | $result = file_get_contents($tmp_file); 280 | } else { 281 | $result = 0; 282 | } 283 | } else { 284 | $result = "NVP"; 285 | } 286 | echo $result; 287 | die(); 288 | } if(isset($_REQUEST['install'])) { 289 | if( $user_level == "viewonly" ) { 290 | die('View-only may not manage versions'); 291 | } 292 | if($_REQUEST['install']!="") { 293 | $js_value = preg_replace('/_/', '.', $_REQUEST['install']); 294 | $version = preg_replace('/[^0-9.]+/', '', $js_value); 295 | $program_dir = $program_dir.$version."/"; 296 | $tmp_file = "/tmp/factorio-version-manager_status.$version.txt"; 297 | if(is_dir($program_dir)) { 298 | $result = "Install failed. Directory exists."; 299 | } else { 300 | if(file_exists($tmp_file)) { 301 | $tmp_file_contents = json_decode(file_get_contents($tmp_file)); 302 | die('Action in progress: '.$tmp_file_contents->action.' by '.$tmp_file_contents->username); 303 | } else { 304 | $result = install($version, $program_dir, $tmp_file); 305 | unlink($tmp_file); 306 | } 307 | } 308 | } else { 309 | $result = "No Version provided"; 310 | } 311 | echo $result; 312 | $log_record = $GLOBALS['time'] ." ". $GLOBALS['date'] ." $version $result : $username \xA"; 313 | file_put_contents( $log_path, $log_record, FILE_APPEND ); 314 | die(); 315 | } elseif( isset( $_REQUEST['delete'] ) ) { 316 | if( $user_level == "viewonly" ) { 317 | die('View-only may not manage versions'); 318 | } 319 | if( $_REQUEST['delete']!="" ) { 320 | $js_value = preg_replace('/_/', '.', $_REQUEST['delete']); 321 | $version = preg_replace( '/[^0-9.]+/', '', $js_value ); 322 | $program_dir = $program_dir.$version."/"; 323 | $tmp_file = "/tmp/factorio-version-manager_status.$version.txt"; 324 | if(is_dir($program_dir)) { 325 | $dir_user = posix_getpwuid( fileowner( $program_dir )); 326 | if( isset( $dir_user['name'] ) && $dir_user['name'] != "www-data" ) { 327 | $result = "Invalid filesystem permissions to remove installation."; 328 | } else { 329 | if( file_exists( $tmp_file ) ) { 330 | $tmp_file_contents = json_decode( file_get_contents( $tmp_file ) ); 331 | die('Action in progress: '.$tmp_file_contents->action.' by '.$tmp_file_contents->username); 332 | } else { 333 | $result = delete($version, $program_dir, $tmp_file); 334 | } 335 | } 336 | } else { 337 | $result = "Version $version not found"; 338 | } 339 | } else { 340 | $result = "No Version provided"; 341 | } 342 | echo $result; 343 | $log_record = $GLOBALS['time'] ." ". $GLOBALS['date'] ." $version $result : $username \xA"; 344 | file_put_contents($log_path, $log_record, FILE_APPEND); 345 | die(); 346 | } elseif(isset($_REQUEST['show'])) { 347 | if($_REQUEST['show']=="true") { 348 | //print_r($server_installed_versions); 349 | echo "

"; 350 | $url = "https://factorio.com/download/archive/"; 351 | $server_matched_versions = get_url($url); 352 | //if a download link is found, iterate the results 353 | if(isset($server_matched_versions[1])) { 354 | foreach($server_matched_versions[1] as $key => $value) { 355 | //find the verion number in the link 356 | //preg_match('~/(.*?)/~', $server_matched_versions[1][$key], $output); 357 | //create array to work with later 358 | $server_available_versions[$value] = $value; 359 | //add to total versions to compare against installed versions 360 | if(!in_array($value, $GLOBALS['total_versions'])) { 361 | $GLOBALS['total_versions'][]=$value; 362 | } 363 | } 364 | } 365 | //display the table for installed and available versions 366 | echo "\xA"; 367 | foreach($GLOBALS['total_versions'] as $value) { 368 | $js_value = preg_replace('#\.#', '_', $value); 369 | echo "\xA"; 397 | } 398 | echo "
VersionControl
$value"; 370 | if(isset($server_available_versions[$value])) { 371 | echo ""; 372 | } else { 373 | echo "depreciated"; 374 | } 375 | //if the server is working on installing a version, this file will exist and hold the status of the install 376 | $tmp_file = "/tmp/factorio-version-manager_status.$value.txt"; 377 | if(file_exists($tmp_file)) { 378 | $tmp_status[$value] = file_get_contents($tmp_file); 379 | } 380 | if(isset($tmp_status[$value])) { 381 | echo "$tmp_status[$value]"; 382 | } else { 383 | //if tmp_file doesn't exist, general rules for if it's installed or not can be displayed 384 | if(isset($server_installed_versions[$value])) { 385 | $path = "/usr/share/factorio/$value"; 386 | $user = posix_getpwuid( fileowner( $path )); 387 | if(isset($user['name'])&&$user['name']!="www-data") { 388 | echo "Installed. Invalid filesystem permissions to delete."; 389 | } else { 390 | echo " - installed"; 391 | } 392 | } else { 393 | echo " "; 394 | } 395 | } 396 | echo "
\xA"; 399 | } 400 | die(); 401 | } 402 | } 403 | ?> 404 | 405 | 406 | 407 | 505 | 506 | 507 | 508 |
509 |
510 | Welcome, ..guest.. -  511 | Home -  512 | Config -  513 | Logs 514 | 515 | 516 |
517 | Logout 518 |
519 |
520 | 521 |
522 |
523 |
    524 |
525 |
526 |
527 |
528 | 529 | 530 | 533 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$EUID" -ne 0 ] 3 | then printf "Please run as root\n" 4 | exit 5 | fi 6 | 7 | #set silent install flag and standard user/password 8 | case $1 in 9 | '-s'|'--silent') silent=1; silent_user=admin; silent_password=password;; 10 | *) silent=0;; 11 | esac 12 | 13 | install_dir="/usr/share/factorio" 14 | supported_node="6.9.5"; 15 | fail_fac_install=false; 16 | 17 | #compressed file extraction function. 0.14 is in tar.gz, and .15 is in tar.xz, for some reason. 18 | function extract_f () { 19 | if [ -f $1 ] ; then 20 | case $1 in 21 | *.tar.gz) tar --strip-components=1 -xzf $1 -C $2/$3; printf "Done!\n";; 22 | *.tar.xz) tar --strip-components=1 -xf $1 -C $2/$3; printf "Done!\n";; 23 | *) printf "Unknown compression type can't extract from $1\n"; fail_fac_install=true; break;; 24 | esac 25 | else 26 | printf "Unable to access file $1... We'll deal with that later...\n" 27 | fail_fac_install=true; 28 | fi 29 | } 30 | 31 | #version checker. Will need this in the case node is already installed 32 | function version_gt () { 33 | test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; 34 | } 35 | 36 | #factorio installation. $1 = install_dir $2 = latest_version 37 | function install_factorio () { 38 | mkdir $1 39 | download=`curl -JLO# https://www.factorio.com/get-download/$2/headless/linux64` 40 | download=`echo $download | awk '{ print $5 }' | tr -d "'"` 41 | if [ "${download}" ]; then 42 | printf "Downloaded to $download\n" 43 | printf "extracting to $1/$2/ ... " 44 | mkdir $1/$2 45 | extract_f $download $1 $2 46 | chown -R www-data:www-data $1/ 47 | else 48 | printf "Unable to download latest version. Don't worry. We can install this later\n" 49 | fi 50 | } 51 | 52 | function install_node () { 53 | url="https://deb.nodesource.com/setup_6.x"; 54 | curl -sL $url | sudo -E bash - 55 | apt install --force-yes --yes nodejs 56 | } 57 | 58 | function set_username(){ 59 | printf "Please enter a username to create:\n" 60 | read username 61 | if [[ -n "$username" ]]; then 62 | a=$(echo $username | tr -d "\n" | wc -c) 63 | b=$(echo $username | tr -cd "[:alnum:]" | wc -c) 64 | if [[ $a != $b ]]; then 65 | printf "Only letters and numbers are supported for usernames.\n" 66 | set_username 67 | else 68 | g_username=$(echo $username | tr -cd "[:alnum:]") 69 | fi 70 | else 71 | printf "Username cannot be left empty.\n" 72 | set_username 73 | fi 74 | } 75 | 76 | function set_password(){ 77 | printf "Enter a password:\n" 78 | read -s password_1 79 | if [[ -n "$password_1" ]]; then 80 | a=$(echo -n $password_1 | md5sum | awk '{ print $1 }') 81 | printf "Re-enter password:\n" 82 | read -s password_2 83 | if [[ -n "$password_2" ]]; then 84 | b=$(echo -n $password_2 | md5sum | awk '{ print $1 }') 85 | if [[ $a != $b ]]; then 86 | printf "Passwords do not match.\n" 87 | set_password 88 | else 89 | g_password=$b 90 | fi 91 | else 92 | printf "Passwords do not match.\n" 93 | set_password 94 | fi 95 | else 96 | printf "Password cannot be left empty.\n" 97 | set_password 98 | fi 99 | } 100 | 101 | printf "Welcome to 3Ra Gaming's Factorio Web Control Installer!\n\n" 102 | #printf "This tool will automatically check that all required dependancies are installed\n" 103 | #printf "If any are not yet installed, it will attempt to install them.\n\n" 104 | printf "This script should verify all dependancies and will attempt to install them.\n" 105 | while [ $silent == 0 ]; do 106 | read -p "Are you currently running Ubuntu 16.04 or higher? [y/n] " yn 107 | case $yn in 108 | [Yy]* ) break;; 109 | [Nn]* ) 110 | printf "\nUnfortunately, this installer was built for Ubuntu :(\n\n"; 111 | printf "Please consult the github for manual instructions\n"; 112 | printf "http://www.3ragaming.com/github\n"; 113 | printf "You may also join our Discord and we will do our best to assist you\n"; 114 | printf "http://www.3ragaming.com/discord\n\n"; 115 | exit;; 116 | * ) echo "Please answer yes[Y] or no[N].";; 117 | esac 118 | done 119 | 120 | #Define web dependencies 121 | #depend_arr+=(""); 122 | web_depend_arr=(); 123 | web_depend_arr+=("apache2"); 124 | web_depend_arr+=("php"); 125 | web_depend_arr+=("php-curl"); 126 | web_depend_arr+=("php-zip"); 127 | web_depend_arr+=("libapache2-mod-php"); 128 | web_insalled=false; 129 | 130 | printf "\nThis script depends on running a web server to function.\n"; 131 | printf "This next step will install Apache2 and PhP, or you may skip this step to step-up your web server manually.\n"; 132 | while [ $silent == 0 ]; do 133 | read -p "Install Apache2 and PhP now? [y/n] " yn 134 | case $yn in 135 | [Yy]* ) 136 | web_installed=true; 137 | break;; 138 | [Nn]* ) 139 | printf "This script will still attempt to install to /var/www/html/\n"; 140 | printf "If you do not wish this, you may cancel the install now.\n"; 141 | printf "Press Enter when ready.\r"; 142 | if [ $silent == 0 ]; then 143 | read 144 | fi 145 | break;; 146 | * ) echo "Please answer yes[Y] or no[N].";; 147 | esac 148 | done 149 | 150 | if [ $silent == 1 ]; then 151 | web_installed=true; 152 | for web_depend_item in "${web_depend_arr[@]}"; do 153 | if ! type $web_depend_item &> /dev/null2>&1; then 154 | apt install --force-yes --yes $web_depend_item 155 | fi 156 | done 157 | fi 158 | 159 | #Define dependencies 160 | #depend_arr+=(""); 161 | depend_arr=(); 162 | depend_arr+=("curl"); 163 | depend_arr+=("zip"); 164 | depend_arr+=("unzip"); 165 | depend_arr+=("tar"); 166 | depend_arr+=("rsync"); 167 | depend_arr+=("gcc"); 168 | depend_arr+=("libcjson-dev"); 169 | depend_arr+=("screen"); 170 | depend_arr+=("cron"); 171 | depend_arr+=("wget"); 172 | depend_arr+=("sudo"); 173 | depend_arr+=("npm"); 174 | depend_arr+=("xz-utils"); 175 | 176 | #Install dependencies 177 | for depend_item in "${depend_arr[@]}"; do 178 | if ! type $depend_item &> /dev/null2>&1; then 179 | apt install --force-yes --yes $depend_item 180 | fi 181 | done 182 | 183 | printf "Base Dependencies Installed!\n\n"; 184 | 185 | #check/install node version 186 | printf "Checking if Node JS is installed\n"; 187 | if ! type node &> /dev/null2>&1; then 188 | printf "Node JS is not installed. Installing.../n"; 189 | install_node; 190 | else 191 | version=`node -v`; 192 | if version_gt $supported_node $version; then 193 | printf "Only node $supported_node and above is supported.\nYou currently have $version installed\n"; 194 | while [ $silent == 0 ]; do 195 | read -p "Attempt to update now? [y/n] " yn 196 | case $yn in 197 | [Yy]* ) break;; 198 | [Nn]* ) 199 | printf "\nPlease manually update your node JS then attempt install again.\n\n"; 200 | exit;; 201 | * ) echo "Please answer yes[Y] or no[N].";; 202 | esac 203 | done 204 | install_node; 205 | fi 206 | fi 207 | if ! type node &> /dev/null2>&1; then 208 | printf "for some reason, Node JS was unable to install. Please manually insatll node js version 6.9.5 or greater, ensure that it is installed with \`which node\`, and run this install script again\n"; 209 | exit; 210 | fi 211 | version=`node -v`; 212 | printf "Node JS $version is installed\n\n"; 213 | 214 | #Factorio Install 215 | if [ ! -d "$install_dir/" ]; then 216 | printf "Factorio is not installed.\nAttempting to identify latest stable version...\n"; 217 | latest_version=`curl -v --silent https://updater.factorio.com/get-available-versions 2>&1 | grep stable | awk '{ print $2 }' | tr -d '"'`; 218 | if [ "${latest_version}" ]; then 219 | printf "Latest stable Factorio version is $latest_version. Installing...\n"; 220 | install_factorio $install_dir $latest_version 221 | if [ -d "$install_dir/" ]; then 222 | printf "Factorio $latest_version installed!\n\n"; 223 | else 224 | printf "Unable to download latest version. Don't worry. We can install this later\n"; 225 | fail_fac_install=true; 226 | fi 227 | else 228 | printf "Unable to download latest version. Don't worry. We can install this later\n"; 229 | fail_fac_install=true; 230 | fi 231 | fi 232 | 233 | printf "Downloading latest version of Web Control\n"; 234 | wget -q https://github.com/3RaGaming/Web_Control/archive/master.zip -O /tmp/master.zip 235 | printf "Unzipping\n"; 236 | unzip -u /tmp/master.zip -d /tmp/ 237 | printf "Creating directories\n"; 238 | mkdir -p /var/www/ 239 | printf "Installing Web Control\n"; 240 | rsync --ignore-existing -a -v /tmp/Web_Control-master/* /var/www/ 241 | printf "Adjusting permissions\n"; 242 | chown -R www-data:www-data /var/www/ 243 | chmod +x /var/www/factorio/manage.sh 244 | chmod +x /var/www/html/update.sh 245 | 246 | config_file="/var/www/factorio/server1/config/config.ini"; 247 | if [ ! -d "/var/www/factorio/server1" ]; then 248 | printf "\"Server1\" not found. Renaming example folder.\n"; 249 | mv /var/www/factorio/serverexample /var/www/factorio/server1 250 | #need to fix read data and save data also 251 | printf "\"Server1\" moved!\n"; 252 | if [ "$fail_fac_install" = true ]; then 253 | printf "Please be sure to insatll a factorio version using the web control before attempting to start a game server\n"; 254 | else 255 | dir="/usr/share/factorio/*"; 256 | for file in $dir; do 257 | first_dir=`echo "$file" | awk -F "/" '{ print $5 }'`; 258 | break; 259 | done 260 | read_data=`grep "read-data" $config_file`; 261 | read_data_new="read-data=/usr/share/factorio/$first_dir/data"; 262 | sed -i -e "s|$read_data|$read_data_new|g" "$config_file" 263 | printf "Updated: $read_data_new\n"; 264 | fi 265 | else 266 | rm -Rf /var/www/factorio/serverexample 267 | fi 268 | 269 | #ensure write-data is set correctly 270 | save_data=`grep "write-data" $config_file`; 271 | #change it to 272 | save_data_new="write-data=/var/www/factorio/server1"; 273 | sed -i -e "s|$save_data|$save_data_new|g" "$config_file" 274 | printf "Updated: $save_data_new\n"; 275 | 276 | printf "We need to install a cronjob for managing deleting old file logs and checking file permissions periodically.\n"; 277 | printf "We will save your current cronjob file as \"cronjob_old.txt\" in case you need to add anything custom back to it\n"; 278 | printf "Press Enter when ready.\r"; 279 | if [ $silent == 0 ]; then 280 | read 281 | fi 282 | printf "Activating cron job for permissions\n"; 283 | crontab -l > cronjob_old.txt 284 | crontab /var/www/cronjob.txt 285 | printf "Compiling managepgm\n"; 286 | cd /var/www/factorio/ 287 | printf "\nPreparing to compile the manager, and install discord js.\n"; 288 | printf "Some warning messages about discord will appear. These are normal, you may ignore them.\n"; 289 | printf "\nPress Enter to continue.\n"; 290 | if [ $silent == 0 ]; then 291 | read 292 | fi 293 | gcc -o managepgm -pthread manage.c 294 | printf "Installing Discord.js\n" 295 | npm install discord.js --save 296 | printf "Cleaning temporary files\n" 297 | rm -Rf /tmp/master.zip /tmp/Web_Control-master/ 298 | if [ "$web_installed" = true ]; then 299 | printf "Enabling SSL and restarting web server\n"; 300 | a2enmod ssl 301 | a2ensite default-ssl 302 | printf "Checking upload limits\n"; 303 | php_ini=`php --ini | grep Loaded | awk '{ print $4 }'` 304 | if [ -f "$php_ini" ]; 305 | then 306 | echo "$php_ini found."; 307 | php_ini_post_max_size_raw=`grep post_max_size $php_ini` 308 | php_ini_post_max_size=`grep post_max_size $php_ini | awk '{ print $3 }' | tr -dc '0-9'` 309 | php_ini_upload_max_filesize_raw=`grep upload_max_filesize $php_ini` 310 | php_ini_upload_max_filesize=`grep upload_max_filesize $php_ini | awk '{ print $3 }' | tr -dc '0-9'` 311 | if [ "$php_ini_post_max_size" -lt "156" ]; then 312 | #change it to 313 | php_ini_post_max_size_raw=`grep post_max_size $php_ini` 314 | php_ini_most_max_size_new="post_max_size = 156M"; 315 | sed -i -e "s/$php_ini_post_max_size_raw/$php_ini_most_max_size_new/g" "$php_ini"; 316 | printf "Updated post_max_size to 156M\n"; 317 | else 318 | printf "$php_ini_post_max_size_raw, this will do\n"; 319 | fi 320 | if [ "$php_ini_upload_max_filesize" -lt "150" ]; then 321 | #change it 322 | php_ini_upload_max_filesize_raw=`grep upload_max_filesize $php_ini` 323 | php_ini_upload_max_filesize_new="upload_max_filesize = 150M"; 324 | sed -i -e "s/$php_ini_upload_max_filesize_raw/$php_ini_upload_max_filesize_new/g" "$php_ini" 325 | printf "Updated upload_max_filesize to 150M\n"; 326 | else 327 | printf "$php_ini_upload_max_filesize_raw, this will do\n"; 328 | fi 329 | else 330 | printf "Unable to location php_ini file.\nYou will be required to change the 'post_max_size' and 'upload_max_filesize' in your php.ini file."; 331 | fi 332 | service apache2 restart 333 | 334 | #request to remove index.html 335 | file="/var/www/html/index.html"; 336 | if [ -f "$file" ]; then 337 | printf "Ubuntu likes to install a default web file at $file\n"; 338 | printf "This file is un-needed and will make using the web control difficult."; 339 | if [ $silent == 0 ]; then 340 | while true; do 341 | read -p "Should we remove this file now? [y/n] " yn 342 | case $yn in 343 | [Yy]* ) 344 | rm -f $file 345 | printf "File $file removed.\n"; 346 | break;; 347 | [Nn]* ) 348 | printf "If you have made this file yourself, please rename it (anything but index) so the web control may function properly.\n"; 349 | printf "Press Enter to continue..."; 350 | read 351 | break;; 352 | * ) echo "Please answer yes[Y] or no[N].";; 353 | esac 354 | done 355 | else 356 | rm -f $file 357 | printf "File $file removed.\n"; 358 | fi 359 | fi 360 | fi 361 | 362 | printf "Installation complete!\n\n"; 363 | printf "We will need to setup a user for you to login without discord authentication for now.\n"; 364 | while [ $silent == 0 ]; do 365 | read -p "Would you like to setup this user now? (This will remove all other users from the users.txt file) [y/n] " yn 366 | case $yn in 367 | [Yy]* ) 368 | set_username 369 | set_password 370 | printf "Will create user \"$g_username\" with password $g_password\n"; 371 | echo "$g_username|$g_password|admin" > /var/www/users.txt; 372 | break;; 373 | [Nn]* ) printf "If you find you cannot login, edit the /var/www/users.txt file.\n"; break;; 374 | * ) echo "Please answer yes[Y] or no[N].";; 375 | esac 376 | done 377 | 378 | #create standard login for silent installation 379 | if [ $silent == 1 ]; then 380 | a=$(echo -n $silent_password | md5sum | awk '{ print $1 }') 381 | echo "$silent_user|$a|admin" > /var/www/users.txt; 382 | fi 383 | 384 | printf "Additional users may be added using additional lines in /var/www/users.txt. Passwords are MD5 encrypted\n"; 385 | printf "Access your site with https://IP_ADDRESS/\n"; 386 | printf "Eventually we will have a splash page for first time logins to assit the rest of the web control setup.\n"; 387 | printf "Until then, the rest of the configuration must be done manually in /var/www/factorio/config.json\n"; 388 | printf "Press Enter to exit.\n"; 389 | if [ $silent == 0 ]; then 390 | read 391 | fi 392 | -------------------------------------------------------------------------------- /users.txt: -------------------------------------------------------------------------------- 1 | admin1|PASSWORD_MD5_HASH_HERE|admin 2 | admin2|PASSWORD_MD5_HASH_HERE|admin 3 | mod1|PASSWORD_MD5_HASH_HERE|admin 4 | guest|PASSWORD_MD5_HASH_HERE|guest 5 | --------------------------------------------------------------------------------