├── .classpath
├── .gitignore
├── LICENSE
├── Manifest
├── README.md
├── build.properties
├── build.xml
├── lang
├── fbeditor_de_DE.properties
├── fbeditor_en_US.properties
├── fbeditor_es_ES.properties
└── fbeditor_it_IT.properties
├── lib
├── commons-codec-1.9.jar
├── commons-httpclient-3.1.jar
└── commons-logging-1.1.1.jar
└── src
├── de
└── FBEditor
│ ├── ActionListen.java
│ ├── BoxInfo.java
│ ├── CutAndPastePopup.java
│ ├── EditMenuListener.java
│ ├── FBEdit.java
│ ├── FindReplace.java
│ ├── FritzBoxConnection.java
│ ├── FritzBoxFirmware.java
│ ├── ImportData.java
│ ├── MyMenu.java
│ ├── exceptions
│ ├── InvalidFirmwareException.java
│ └── WrongPasswordException.java
│ ├── font
│ └── Consola.ttf
│ ├── simpletests
│ └── NewChallengeTest.java
│ ├── struct
│ ├── CompoundUndoManager.java
│ ├── ExampleFileFilter.java
│ ├── FBFWVN.java
│ ├── FbQueryLua.java
│ ├── HttpPost.java
│ ├── JTextPane2.java
│ ├── MyHighlightPainter.java
│ ├── MyProperties.java
│ ├── OverwriteCaret.java
│ └── SIDLogin.java
│ └── utils
│ ├── CalcChecksum.java
│ ├── Debug.java
│ ├── Encryption.java
│ ├── HTMLUtil.java
│ ├── Listener.java
│ ├── LogSeverity.java
│ ├── StringPartNoTransferEncoding.java
│ ├── Utils.java
│ └── upnp
│ ├── MyAuthenticator.java
│ └── UPNPUtils.java
└── icon.gif
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.project
2 | /FBEditor.properties.xml
3 | /.settings
4 | /bin
5 | /build/*
6 | /.externalToolBuilders
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/Manifest:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.2
2 | Main-Class: de.FBEditor.FBEdit
3 | Class-Path:
4 | Created-By: 1.5 (Sun Microsystems Inc.)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FBEditor
2 | --------
3 |
4 | Der FBEditor ist ein Programm mit dem man die Konfiguration einer AVM Fritz!Box importieren, editieren und exportieren kann.
5 | Zum Im-/Export der Konfiguration wird die "Einstellungen sichern"-Funktion des Webinterfaces benutzt. => Es ist nicht möglich die debug.cfg damit zu ändern.
6 |
7 | Diskussion
8 | ----------
9 | DE - http://www.ip-phone-forum.de/showthread.php?t=79513
10 |
11 | IT - https://www.hwupgrade.it/forum/showthread.php?p=45620145
12 |
--------------------------------------------------------------------------------
/build.properties:
--------------------------------------------------------------------------------
1 | app.name=FBEditor
2 | app.version=0.7
3 | main.class=de.FBEditor.FBEdit
4 | build.dir=build
5 | classes.dir=${build.dir}/classes
6 | jar.dir=${build.dir}/jar
7 | dist.dir=dist
8 | src.dir=src
9 | lang.dir=lang
10 | test.dir=test
11 | lib.dir=lib
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | My description.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
60 |
61 |
69 |
70 |
--------------------------------------------------------------------------------
/lang/fbeditor_de_DE.properties:
--------------------------------------------------------------------------------
1 | #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
2 | #Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
3 |
4 | box.affirmation = Sind sie sicher, dass sie die Konfiguration auf die Fritz!Box zur\u00FCckspielen wollen?\nDer Autor dieses Programms \u00FCbernimmt keine Haftung f\u00FCr defekte Boxen!
5 | box.get_config = Hole Konfiguration von Fritz!Box.\nBitte warten...
6 | box.login_lua = Box Login Lua ab Firmware Version xxx.05.50
7 | box.not_found = Fritz!Box wurde nicht gefunden.\nBitte die Einstellungen pr\u00FCfen.
8 | box.restart = Die Einstellungen wurden erfolgreich wiederhergestellt.\nDie Fritz!Box startet jetzt neu.\n
9 | box.settings_error = Die Konfiguration ist fehlerhaft und konnte nicht zur\u00FCckgespielt werden!
10 |
11 | boxinfo.firmware = Firmware:
12 | boxinfo.hardware = Hardware:
13 | boxinfo.modversion = Mod-Version:
14 | boxinfo.nomod = original Firmware
15 |
16 | export.file = Export-Datei
17 | export.load.error = Fehler: Datei konnte nicht geladen werden.
18 | export.save.error = Fehler: Datei konnte nicht gespeichert werden.
19 |
20 | find.cancel = Abbrechen
21 | find.continue = Weitersuchen
22 | find.replace = Ersetzen
23 | find.search = Suchen
24 | find.searchall = Alle Suchen
25 | find.searchandreplace = Suchen und Ersetzen
26 |
27 | main.2fa = 2FA
28 | main.2fa_info = W\u00E4hlen Sie auf der Fritzbox-Weboberfl\u00E4che:\r\n\r\nSystem -> Fritzbox Benutzer -> Registrierung im Heimnetzwerk\r\n-> Best\u00E4tigen -> H\u00E4kchen entfernen
29 | main.2fa_is_active = 2FA ist Aktiv
30 | main.error = Fehler
31 | main.programcreatorinfo = Diese Software Version wurde erstellt von:
32 | main.thanks = Mein Dank geht an Enrik Berkhan, Andreas B\u00FChmann \nund an das JFritz-Team.\n
33 | main.tr64upnp = tr64upnp
34 | main.tr64upnp_is_active = ist Aktiv
35 | main.unknown_file = unbenannt
36 |
37 | menu.about = \u00DCber
38 | menu.automatic_detection = Automatische Erkennung
39 | menu.boxinfo = Boxinfo
40 | menu.close = Schlie\u00DFen
41 | menu.config_auto_read = Konfiguration automatisch einlesen
42 | menu.config_read = Konfiguration einlesen
43 | menu.config_save = Speichern
44 | menu.config_write = Konfiguration zur\u00FCckspielen
45 | menu.configimexpwd = Kennwort Sicherungsdatei
46 | menu.copy = Kopieren
47 | menu.cut = Ausschneiden
48 | menu.delete = L\u00F6schen
49 | menu.edit = Bearbeiten
50 | menu.exit = Beenden
51 | menu.file = Datei
52 | menu.help = Hilfe
53 | menu.host_ip = Hostname / IP-Adresse
54 | menu.insert = Einf\u00FCgen
55 | menu.language = Sprache
56 | menu.line = Zeile
57 | menu.markall = Alles markieren
58 | menu.national_language_english = Englisch
59 | menu.national_language_german = Deutsch
60 | menu.national_language_italian = Italienisch
61 | menu.national_language_spanish = Spanisch
62 | menu.new = Neu
63 | menu.nochecks = NoChecks
64 | menu.open = \u00D6ffnen
65 | menu.password = Passwort
66 | menu.program_start_dialog = Einstellungsdialog bei jedem Programmstart Anzeigen
67 | menu.reconnect = Neu verbinden
68 | menu.refresh_checksum = Checksumme Aktualisieren
69 | menu.replace = Ersetzen
70 | menu.restore = Wiederherstellen
71 | menu.revert = R\u00FCckg\u00E4ngig
72 | menu.search = Suchen
73 | menu.settings = Einstellungen
74 | menu.username = Benutzername
75 |
76 | settings.ConfigImExPwd = Kennwort der Sicherungsdatei
77 | settings.backup = Einstellungen wiederherstellen
78 | settings.host_ip = Hostname / IP-Adresse:
79 | settings.password = Passwort
80 | settings.username = Benutzername
81 |
82 | utils.read_error = Beim Einlesen der Daten ist ein Fehler aufgetreten!
83 | utils.restore_error = Beim Zur\u00FCckspielen ist ein Fehler aufgetreten!
84 |
85 | window.close = Fenster schlie\u00DFen
86 |
--------------------------------------------------------------------------------
/lang/fbeditor_en_US.properties:
--------------------------------------------------------------------------------
1 | #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
2 | #Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
3 |
4 | box.affirmation = Are you sure that you want to Upload this configuration to your Fritz!Box?\nThe author will not assume responsibility for bricked devices!
5 | box.get_config = Getting configuration from Fritz!Box.\nPlease wait...
6 | box.login_lua = Box Login Lua from firmware version xxx.05.50
7 | box.not_found = Fritz!Box not found.\nPlease check your settings.
8 | box.restart = The settings were restored sucessfully .\nYour Fritz!Box reboots now.\n
9 | box.settings_error = The configuration is incorrect and could not be restored.
10 |
11 | boxinfo.firmware = Firmware:
12 | boxinfo.hardware = Hardware:
13 | boxinfo.modversion = Mod-Version:
14 | boxinfo.nomod = original firmware
15 |
16 | export.file = Exportfile
17 | export.load.error = Error: Could not load file
18 | export.save.error = Error: Could not save file
19 |
20 | find.cancel = Cancel
21 | find.continue = Continue
22 | find.replace = Replace
23 | find.search = Search
24 | find.searchall = Search All
25 | find.searchandreplace = Search and Replace
26 |
27 | main.2fa = 2FA
28 | main.2fa_info = From the Fritzbox web interface, select:\r\n\r\nSystem -> Fritzbox users -> Registration in the home network\r\n-> Confirm -> Remove the check mark
29 | main.2fa_is_active = 2FA is Active
30 | main.error = Error
31 | main.programcreatorinfo = This software version was created by:
32 | main.thanks = My thanks go to Enrik Berkhan, Andreas B\u00FChmann \nand the JFritz-Team.\n
33 | main.tr64upnp = tr64upnp
34 | main.tr64upnp_is_active = is Active
35 | main.unknown_file = unnamed
36 |
37 | menu.about = About
38 | menu.automatic_detection = Automatic detection
39 | menu.boxinfo = Boxinfo
40 | menu.close = Close
41 | menu.config_auto_read = Read configuration on startup
42 | menu.config_read = Read configuration
43 | menu.config_save = Save
44 | menu.config_write = Restore configuration
45 | menu.configimexpwd = Password backup file
46 | menu.copy = Copy
47 | menu.cut = Cut
48 | menu.delete = Delete
49 | menu.edit = Edit
50 | menu.exit = Exit
51 | menu.file = File
52 | menu.help = Help
53 | menu.host_ip = Hostname / IP-Address
54 | menu.insert = Insert
55 | menu.language = Language
56 | menu.line = line
57 | menu.markall = Mark all
58 | menu.national_language_english = English
59 | menu.national_language_german = German
60 | menu.national_language_italian = Italian
61 | menu.national_language_spanish = Spanish
62 | menu.new = New
63 | menu.nochecks = NoChecks
64 | menu.open = Open
65 | menu.password = Password
66 | menu.program_start_dialog = Settings Dialog at every Program start Display
67 | menu.reconnect = Reconnect
68 | menu.refresh_checksum = Refresh Checksum
69 | menu.replace = Replace
70 | menu.restore = Restore
71 | menu.revert = Revert
72 | menu.search = Search
73 | menu.settings = Settings
74 | menu.username = Username
75 |
76 | settings.ConfigImExPwd = Password for the backup file
77 | settings.backup = Restore configuration
78 | settings.host_ip = Hostname / IP-Address:
79 | settings.password = Password
80 | settings.username = Username
81 |
82 | utils.read_error = An error occured while reading the configuration.
83 | utils.restore_error = An error occured while restoring configuration!
84 |
85 | window.close = Close window
86 |
--------------------------------------------------------------------------------
/lang/fbeditor_es_ES.properties:
--------------------------------------------------------------------------------
1 | #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
2 | #Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
3 |
4 | box.affirmation = Esta seguro de transferir la configuraci\u00F3n al Fritz!Box?\nEl El autor de este programa no se hace responsable por routers con defecto!
5 | box.get_config = Recogiendo la configuraci\u00F3n del Fritz!Box.\nFavor de esperar...
6 | box.login_lua = Box Login Lua de la versi\u00F3n de firmware xxx.05.50
7 | box.not_found = No se encontro el Fritz!Box.\nFavor de checar la configuraci\u00F3n.
8 | box.restart = La configuraci\u00F3n se restauro con exito.\nEl Fritz!Box se reinicia.\n
9 | box.settings_error = La configuraci\u00F3n presenta errores y no se pudo transferir al Fritz!Box!
10 |
11 | boxinfo.firmware = Firmware:
12 | boxinfo.hardware = Hardware:
13 | boxinfo.modversion = Mod-Version:
14 | boxinfo.nomod = Firmware original
15 |
16 | export.file = Archivo de exportaci\u00F3n
17 | export.load.error = Error: No se pudo cargar el archivo.
18 | export.save.error = Error: No se pudo guardar el archivo.
19 |
20 | find.cancel = Cancelar
21 | find.continue = Seguir
22 | find.replace = Reemplazar
23 | find.search = Buscar
24 | find.searchall = Busca Todo
25 | find.searchandreplace = Buscar y Reemplazar
26 |
27 | main.2fa = 2FA
28 | main.2fa_info = Desde la interfaz web de Fritzbox, seleccione:\r\n\r\nSistema -> Usuarios de Fritzbox -> Registro en la red dom\u00E9stica\r\n-> Confirmar -> Eliminar la marca de verificaci\u00F3n
29 | main.2fa_is_active = 2FA es Activo
30 | main.error = Error
31 | main.programcreatorinfo = Esta versi\u00F3n de software fue creada por:
32 | main.thanks = Mis agradecimientos van a Enrik Berkhan, Andreas B\u00FChmann \ny al equipo de JFritz.\n
33 | main.tr64upnp = tr64upnp
34 | main.tr64upnp_is_active = es Activo
35 | main.unknown_file = sin nombre
36 |
37 | menu.about = sobre
38 | menu.automatic_detection = Detecci\u00F3n autom\u00E1tica
39 | menu.boxinfo = Boxinfo
40 | menu.close = Cerrar
41 | menu.config_auto_read = Recoger automaticamente la configuraci\u00F3n
42 | menu.config_read = Recoger configuraci\u00F3n
43 | menu.config_save = Guardar
44 | menu.config_write = Transferir configuraci\u00F3n
45 | menu.configimexpwd = Archivo de copia de seguridad de contrase\u00F1a
46 | menu.copy = Copiar
47 | menu.cut = Cortar
48 | menu.delete = Borrar
49 | menu.edit = Editar
50 | menu.exit = Cerrar
51 | menu.file = Archivo
52 | menu.help = Ayuda
53 | menu.host_ip = Hostname / Direcci\u00F3n-IP
54 | menu.insert = Insertar
55 | menu.language = Idioma
56 | menu.line = Linea
57 | menu.markall = Marcar todo
58 | menu.national_language_english = Ingl\u00E9s
59 | menu.national_language_german = alem\u00E1n
60 | menu.national_language_italian = italiano
61 | menu.national_language_spanish = espa\u00F1ol
62 | menu.new = Nuevo
63 | menu.nochecks = NoChecks
64 | menu.open = abrir
65 | menu.password = Contrase\u00F1a
66 | menu.program_start_dialog = Di\u00E1logo de configuraci\u00F3n en cada inicio de programa Pantalla
67 | menu.reconnect = Reconnectar
68 | menu.refresh_checksum = Actualizar suma de comprobaci\u00F3n
69 | menu.replace = Reemplazar
70 | menu.restore = Restaurar
71 | menu.revert = Regresar
72 | menu.search = Buscar
73 | menu.settings = Propiedades
74 | menu.username = Nombre de usario
75 |
76 | settings.ConfigImExPwd = Contrase\u00F1a para el archivo de copia de seguridad
77 | settings.backup = Restaurar propiedades
78 | settings.host_ip = Hostname / Direcci\u00F3n-IP:
79 | settings.password = Contrase\u00F1a
80 | settings.username = Nombre de usario
81 |
82 | utils.read_error = Se presento un error abriendo los datos!
83 | utils.restore_error = Se presento un error en la transferencia!
84 |
85 | window.close = Cerrar ventana
86 |
--------------------------------------------------------------------------------
/lang/fbeditor_it_IT.properties:
--------------------------------------------------------------------------------
1 | #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
2 | #Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
3 |
4 | box.affirmation = Sei sicuro di voler ripristinare questa configurazione nel Fritz!Box?\nL'autore del programma non si assume nessuna responsabilit\u00E0 in caso di blocco del modem!
5 | box.get_config = Verifica configurazione Fritz!Box.\nAttendi...
6 | box.login_lua = Box Login Lua dalla versione firmware xxx.05.50
7 | box.not_found = Non \u00E8 stato trovato nessun modem FRITZ!Box.\nVerifica le impostazioni.
8 | box.restart = Ripristino file configurazione completato.\nRiavvio Fritz!Box.\n
9 | box.settings_error = La configurazione non \u00E8 corretta e non pu\u00F2 essere ripristinata.
10 |
11 | boxinfo.firmware = Firmware:
12 | boxinfo.hardware = Hardware:
13 | boxinfo.modversion = Versione-mod:
14 | boxinfo.nomod = firmware originale
15 |
16 | export.file = Esporta file
17 | export.load.error = Errore: impossibile caricare il file
18 | export.save.error = Errore: impossibile salvare il file
19 |
20 | find.cancel = Annulla
21 | find.continue = Continua
22 | find.replace = Sostituisci
23 | find.search = Cerca
24 | find.searchall = Cerca tutti
25 | find.searchandreplace = Cerca e sostituisci
26 |
27 | main.2fa = 2FA
28 | main.2fa_info = Nell'interfaccia web del Fritzbox seleziona:\r\n\r\nSistema -> Utenti Fritzbox -> Registrazione nella rete domestica\r\n-> Conferma -> Togli la spunta
29 | main.2fa_is_active = 2FA \u00E8 Attivo
30 | main.error = Errore
31 | main.programcreatorinfo = Questa versione del software \u00E8 stata creata da:
32 | main.thanks = I miei ringraziamenti a\nEnrik Berkhan, Andreas B\u00FChmann e al JFritz-Team.\n
33 | main.tr64upnp = tr64upnp
34 | main.tr64upnp_is_active = \u00E8 Attivo
35 | main.unknown_file = senza nome
36 |
37 | menu.about = Info sul programma
38 | menu.automatic_detection = Rilevamento automatico
39 | menu.boxinfo = Informazioni
40 | menu.close = Chiudi
41 | menu.config_auto_read = Leggi configurazione all'avvio
42 | menu.config_read = Leggi configurazione
43 | menu.config_save = Salva
44 | menu.config_write = Carica configurazione
45 | menu.configimexpwd = Password file backup
46 | menu.copy = Copia
47 | menu.cut = Taglia
48 | menu.delete = Elimina
49 | menu.edit = Modifica
50 | menu.exit = Esci
51 | menu.file = File
52 | menu.help = Aiuto
53 | menu.host_ip = Nome host / indirizzo IP
54 | menu.insert = Inserisci
55 | menu.language = Lingua
56 | menu.line = linea
57 | menu.markall = Segna tutto
58 | menu.national_language_english = Inglese
59 | menu.national_language_german = Tedesco
60 | menu.national_language_italian = Italiano
61 | menu.national_language_spanish = Spagnolo
62 | menu.new = Nuovo
63 | menu.nochecks = Nessun controllo
64 | menu.open = Apri
65 | menu.password = Password
66 | menu.program_start_dialog = All'avvio visualizza finestra 'Impostazioni'
67 | menu.reconnect = Riconnetti
68 | menu.refresh_checksum = Aggiorna checksum
69 | menu.replace = Sostituisci
70 | menu.restore = Ripristina
71 | menu.revert = Torna a precedente
72 | menu.search = Cerca
73 | menu.settings = Impostazioni
74 | menu.username = Utente
75 |
76 | settings.ConfigImExPwd = Password file backup
77 | settings.backup = Ripristina configurazione
78 | settings.host_ip = Nome host / indirizzo IP:
79 | settings.password = Password
80 | settings.username = Utente
81 |
82 | utils.read_error = Si \u00E8 verificato un errore durante la lettura della configurazione!
83 | utils.restore_error = Si \u00E8 verificato un errore durante il ripristino della configurazione!
84 |
85 | window.close = Chiudi finestra
86 |
--------------------------------------------------------------------------------
/lib/commons-codec-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olistudent/FBEditor/2732f261e1448ad7135f5da818050fc7760eaa32/lib/commons-codec-1.9.jar
--------------------------------------------------------------------------------
/lib/commons-httpclient-3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olistudent/FBEditor/2732f261e1448ad7135f5da818050fc7760eaa32/lib/commons-httpclient-3.1.jar
--------------------------------------------------------------------------------
/lib/commons-logging-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olistudent/FBEditor/2732f261e1448ad7135f5da818050fc7760eaa32/lib/commons-logging-1.1.1.jar
--------------------------------------------------------------------------------
/src/de/FBEditor/ActionListen.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.awt.event.ActionEvent;
4 | import java.awt.event.ActionListener;
5 |
6 | class ActionListen implements ActionListener {
7 |
8 | public ActionListen(FBEdit fbedit) {
9 | this.fbedit = fbedit;
10 | }
11 |
12 | public void actionPerformed(ActionEvent event) {
13 | CutAndPastePopup cutAndPaste = fbedit.getCutAndPaste();
14 | cutAndPaste.updateSource(fbedit.getEditor());
15 |
16 | switch (event.getActionCommand()) {
17 | case "exit":
18 | fbedit.exit();
19 | break;
20 | case "open":
21 | fbedit.loadFile();
22 | break;
23 | case "new":
24 | fbedit.newFile();
25 | break;
26 | case "save":
27 | fbedit.saveFile();
28 | break;
29 | case "reconnect":
30 | FBEdit.makeNewConnection(false);
31 | break;
32 | case "about":
33 | fbedit.about();
34 | break;
35 | case "config_read":
36 | fbedit.getFile();
37 | break;
38 | case "config_auto_read":
39 | fbedit.changeRAS();
40 | break;
41 | case "nochecks":
42 | fbedit.changeNoChecks();
43 | break;
44 | case "config_write":
45 | fbedit.putFile();
46 | break;
47 | case "host_ip":
48 | fbedit.getHost(false);
49 | break;
50 | case "password":
51 | fbedit.getPassword(false);
52 | break;
53 | case "username":
54 | fbedit.getUsername(false);
55 | break;
56 | case "box_login_lua": // 25.06.2018
57 | fbedit.changeBoxLoginLua();
58 | break;
59 | case "program_start_dialog": // 25.06.2018
60 | fbedit.changeProgramStartDialog();
61 | break;
62 | // case "configimexpwd":
63 | // fbedit.getConfigImExPwd(false);
64 | // break;
65 | case "boxinfo":
66 | fbedit.showBoxInfo();
67 | break;
68 | case "search":
69 | fbedit.search();
70 | break;
71 | case "replace":
72 | fbedit.replace();
73 | break;
74 | case "cut":
75 | cutAndPaste.cut();
76 | break;
77 | case "copy":
78 | cutAndPaste.copy();
79 | break;
80 | case "insert":
81 | cutAndPaste.paste();
82 | break;
83 | case "delete":
84 | cutAndPaste.delete();
85 | break;
86 | case "markall":
87 | cutAndPaste.markall();
88 | break;
89 | case "revert":
90 | fbedit.undoredo(1);
91 | break;
92 | case "restore":
93 | fbedit.undoredo(2);
94 | break;
95 | default:
96 | // TODO unknown action listener
97 | System.out.println("unknown action listener: " + event.getActionCommand());
98 | break;
99 | }
100 | }
101 |
102 | private FBEdit fbedit;
103 | public static final int addundo = 1;
104 | public static final int addredo = 2;
105 | }
106 |
--------------------------------------------------------------------------------
/src/de/FBEditor/BoxInfo.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.GridBagConstraints;
5 | import java.awt.GridBagLayout;
6 | import java.awt.GridLayout;
7 | import java.io.IOException;
8 |
9 | import javax.swing.JButton;
10 | import javax.swing.JDialog;
11 | import javax.swing.JEditorPane;
12 | import javax.swing.JLabel;
13 | import javax.swing.JPanel;
14 | import javax.swing.JScrollPane;
15 |
16 | import de.FBEditor.exceptions.InvalidFirmwareException;
17 | import de.FBEditor.exceptions.WrongPasswordException;
18 |
19 | public class BoxInfo extends JDialog {
20 |
21 | private static final long serialVersionUID = 1L;
22 | private JPanel jPanel = null;
23 | private JButton jButton = null;
24 | private JScrollPane jScrollPane = null;
25 | private JEditorPane fbeditorPane = null;
26 | private JPanel jPanel1 = null;
27 | private JLabel jLabel2;
28 | private JLabel jLabel4;
29 | private JLabel jLabel6;
30 |
31 | /**
32 | * This is the default constructor
33 | * @throws InvalidFirmwareException
34 | * @throws IOException
35 | * @throws WrongPasswordException
36 | */
37 | public BoxInfo(String boxName, String firmwareVersion, String modVersion) {
38 | super();
39 |
40 | this.setSize(500, 300);
41 | this.setTitle(FBEdit.getMessage("menu.boxinfo"));
42 | this.setIconImage(FBEdit.getInstance().getImageFromJAR("/icon.gif"));
43 | this.setContentPane(getJPanel());
44 | this.setLocationRelativeTo(FBEdit.getInstance().getframe());
45 | this.setVisible(true);
46 |
47 | setPanelText(boxName, firmwareVersion, modVersion);
48 | }
49 |
50 | /**
51 | * This method initializes jPanel
52 | *
53 | * @return javax.swing.JPanel
54 | */
55 | private JPanel getJPanel() {
56 | if (jPanel == null) {
57 | GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
58 | // gridBagConstraints2.insets = new java.awt.Insets(53,3,112,74);
59 | gridBagConstraints2.gridy = 1;
60 | gridBagConstraints2.gridx = 0;
61 | gridBagConstraints2.weightx = 1.0;
62 | gridBagConstraints2.weighty = 0.25;
63 | gridBagConstraints2.fill = 1;
64 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
65 | gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
66 | gridBagConstraints1.gridx = 0;
67 | gridBagConstraints1.gridy = 0;
68 | // gridBagConstraints1.weightx = 1.0;
69 | gridBagConstraints1.weighty = 0.65;
70 | gridBagConstraints1.fill = 1;
71 | // gridBagConstraints1.insets = new java.awt.Insets(5,3,64,2);
72 | GridBagConstraints gridBagConstraints = new GridBagConstraints();
73 | // gridBagConstraints.insets = new java.awt.Insets(100,74,159,2);
74 | gridBagConstraints.gridy = 2;
75 | gridBagConstraints.gridx = 0;
76 | // gridBagConstraints.weightx = 1.0;
77 | gridBagConstraints.weighty = 0.1;
78 | jPanel = new JPanel();
79 | jPanel.setLayout(new GridBagLayout());
80 | jPanel.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
81 | jPanel.add(getJButton(), gridBagConstraints);
82 | jPanel.add(getJScrollPane(), gridBagConstraints1);
83 | jPanel.add(getJPanel1(), gridBagConstraints2);
84 | }
85 | return jPanel;
86 | }
87 |
88 | /**
89 | * This method initializes jButton
90 | *
91 | * @return javax.swing.JButton
92 | */
93 | private JButton getJButton() {
94 | if (jButton == null) {
95 | jButton = new JButton();
96 | jButton.setPreferredSize(new java.awt.Dimension(115, 35));
97 | jButton.setText(FBEdit.getMessage("menu.close"));
98 | jButton.setToolTipText(FBEdit.getMessage("window.close"));
99 | jButton.setName("close");
100 | jButton.addActionListener(new java.awt.event.ActionListener() {
101 | public void actionPerformed(java.awt.event.ActionEvent e) {
102 | setVisible(false);
103 | }
104 | });
105 | }
106 | return jButton;
107 | }
108 |
109 | /**
110 | * This method initializes jScrollPane
111 | *
112 | * @return javax.swing.JScrollPane
113 | */
114 | private JScrollPane getJScrollPane() {
115 | if (jScrollPane == null) {
116 | jScrollPane = new JScrollPane();
117 | jScrollPane.setPreferredSize(new java.awt.Dimension(200, 200));
118 | jScrollPane.setViewportView(getJEditorPane());
119 | }
120 | return jScrollPane;
121 | }
122 |
123 | /**
124 | * This method initializes fbeditorPane
125 | *
126 | * @return javax.swing.fbeditorPane
127 | */
128 | private JEditorPane getJEditorPane() {
129 | if (fbeditorPane == null) {
130 | try {
131 | String url = (new StringBuilder("http://")).append(FBEdit.getInstance().getbox_address()).append("/cgi-bin/system_status").toString();
132 | fbeditorPane = new JEditorPane(url);
133 | } catch (IOException e) {
134 | e.printStackTrace();
135 | }
136 | }
137 | return fbeditorPane;
138 | }
139 |
140 | /**
141 | * This method initializes jPanel1
142 | *
143 | * @return javax.swing.JPanel
144 | */
145 | private JPanel getJPanel1() {
146 | if (jPanel1 == null) {
147 | jPanel1 = new JPanel();
148 | jPanel1.setLayout(new GridLayout(4, 2));
149 | JLabel jLabel = new JLabel(FBEdit.getMessage("boxinfo.hardware"));
150 | jLabel.setPreferredSize(new Dimension(100, 26));
151 | jPanel1.add(jLabel);
152 | jLabel2 = new JLabel();
153 | jLabel2.setPreferredSize(new Dimension(100, 26));
154 | jPanel1.add(jLabel2);
155 | jLabel = new JLabel(FBEdit.getMessage("boxinfo.firmware"));
156 | jLabel.setPreferredSize(new Dimension(100, 26));
157 | jPanel1.add(jLabel);
158 | jLabel4 = new JLabel();
159 | jLabel4.setPreferredSize(new Dimension(100, 26));
160 | jPanel1.add(jLabel4);
161 | jLabel = new JLabel(FBEdit.getMessage("boxinfo.modversion"));
162 | jLabel.setPreferredSize(new Dimension(100, 26));
163 | jPanel1.add(jLabel);
164 | jLabel6 = new JLabel();
165 | jLabel6.setPreferredSize(new Dimension(100, 26));
166 | jPanel1.add(jLabel6);
167 | }
168 | return jPanel1;
169 | }
170 |
171 | public void setPanelText(String boxName, String firmwareVersion, String modVersion) {
172 | jLabel2.setText(boxName);
173 | jLabel4.setText(firmwareVersion);
174 | /*
175 | if (modVersion.equals(""))
176 | jLabel6.setText(FBEdit.getMessage("boxinfo.nomod"));
177 | else
178 | jLabel6.setText(modVersion);
179 | */
180 | if (modVersion.equals("")) {
181 | jLabel6.setText(FBEdit.getMessage("boxinfo.nomod"));
182 | } else {
183 | jLabel6.setText(modVersion);
184 | }
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/src/de/FBEditor/CutAndPastePopup.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.awt.datatransfer.Clipboard;
4 | import java.awt.datatransfer.ClipboardOwner;
5 | import java.awt.datatransfer.DataFlavor;
6 | import java.awt.datatransfer.StringSelection;
7 | import java.awt.datatransfer.Transferable;
8 |
9 | import javax.swing.JComponent;
10 | import javax.swing.JMenuItem;
11 | import javax.swing.JPopupMenu;
12 | import javax.swing.text.JTextComponent;
13 |
14 | /**
15 | * Rightclick menu
16 | *
17 | */
18 | public class CutAndPastePopup extends JComponent implements ClipboardOwner {
19 |
20 | public CutAndPastePopup(ActionListen action) {
21 |
22 | popupMenu = new JPopupMenu();
23 | popupMenu.setLabel(FBEdit.getMessage("menu.edit"));
24 |
25 | // hier noch nicht implementiert
26 | // revert = new JMenuItem("Rückgängig");
27 | cut = new JMenuItem(FBEdit.getMessage("menu.cut"));
28 | copy = new JMenuItem(FBEdit.getMessage("menu.copy"));
29 | insert = new JMenuItem(FBEdit.getMessage("menu.insert"));
30 | delete = new JMenuItem(FBEdit.getMessage("menu.delete"));
31 | markall = new JMenuItem(FBEdit.getMessage("menu.markall"));
32 |
33 | clipbd = getToolkit().getSystemClipboard();
34 | // undoManager = fbedit.getUndoManager();
35 |
36 | cut.setActionCommand("cut");
37 | copy.setActionCommand("copy");
38 | insert.setActionCommand("insert");
39 | delete.setActionCommand("delete");
40 | markall.setActionCommand("markall");
41 |
42 | cut.addActionListener(action);
43 | copy.addActionListener(action);
44 | insert.addActionListener(action);
45 | delete.addActionListener(action);
46 | markall.addActionListener(action);
47 |
48 | // revert.addActionListener(this);
49 | // revert.setEnabled(false);
50 | // popupMenu.add(revert);
51 | // popupMenu.addSeparator();
52 |
53 | popupMenu.add(cut);
54 | popupMenu.add(copy);
55 | popupMenu.add(insert);
56 | popupMenu.add(delete);
57 | popupMenu.addSeparator();
58 | popupMenu.add(markall);
59 | }
60 |
61 | public void updateMenu() {
62 | if (source.getSelectedText() != null) {
63 | copy.setEnabled(true);
64 | cut.setEnabled(true);
65 | delete.setEnabled(true);
66 | } else {
67 | copy.setEnabled(false);
68 | cut.setEnabled(false);
69 | delete.setEnabled(false);
70 | }
71 | if (clipbd.getContents(this) != null)
72 | insert.setEnabled(true);
73 | else
74 | insert.setEnabled(false);
75 | // revert.setEnabled(undoManager.canUndo());
76 | }
77 |
78 | public void lostOwnership(Clipboard c, Transferable t) {
79 | selection = null;
80 | }
81 |
82 | public void updateSource(JTextComponent source) {
83 | this.source = source;
84 | }
85 |
86 | public void cut() {
87 | selection = source.getSelectedText();
88 | StringSelection clipString = new StringSelection(selection);
89 | clipbd.setContents(clipString, clipString);
90 | source.replaceSelection("");
91 | /* updateMenu(); */
92 | }
93 |
94 | public void copy() {
95 | selection = source.getSelectedText();
96 | StringSelection clipString = new StringSelection(selection);
97 | clipbd.setContents(clipString, clipString);
98 | /* updateMenu(); */
99 | }
100 |
101 | public void markall() {
102 | source.setSelectionStart(0);
103 | source.setSelectionEnd(source.getDocument().getLength());
104 | /* updateMenu(); */
105 | }
106 |
107 | public void paste() {
108 | Transferable clipData = clipbd.getContents(this);
109 | try {
110 | String clipString = (String) clipData.getTransferData(DataFlavor.stringFlavor);
111 | source.replaceSelection(clipString);
112 | /* updateMenu(); */
113 | } catch (Exception ex) {
114 | System.out.println("not String flavor");
115 | }
116 | }
117 |
118 | public void delete() {
119 | selection = source.getSelectedText();
120 | source.replaceSelection("");
121 | /* updateMenu(); */
122 | }
123 |
124 | public JPopupMenu getPopupMenu() {
125 | return popupMenu;
126 | }
127 |
128 | private static final long serialVersionUID = 1L;
129 | private static JPopupMenu popupMenu;
130 | private Clipboard clipbd;
131 | private String selection;
132 | JMenuItem revert;
133 | JMenuItem cut;
134 | JMenuItem copy;
135 | JMenuItem insert;
136 | JMenuItem delete;
137 | JMenuItem markall;
138 | JTextComponent source;
139 | // CompoundUndoManager undoManager;
140 | }
141 |
--------------------------------------------------------------------------------
/src/de/FBEditor/EditMenuListener.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import javax.swing.event.MenuEvent;
4 | import javax.swing.event.MenuListener;
5 |
6 | class EditMenuListener implements MenuListener {
7 |
8 | public EditMenuListener(FBEdit fbedit) {
9 | this.fbedit = fbedit;
10 | }
11 |
12 | public void menuSelected(MenuEvent e) {
13 | fbedit.updateMenu(fbedit.getMenu());
14 | }
15 |
16 | public void menuCanceled(MenuEvent menuevent) {
17 | }
18 |
19 | public void menuDeselected(MenuEvent menuevent) {
20 | }
21 |
22 | private FBEdit fbedit;
23 | }
24 |
--------------------------------------------------------------------------------
/src/de/FBEditor/FindReplace.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.ActionListener;
7 |
8 | import javax.swing.BoxLayout;
9 | import javax.swing.JButton;
10 | import javax.swing.JDialog;
11 | import javax.swing.JLabel;
12 | import javax.swing.JPanel;
13 | import javax.swing.JTextField;
14 |
15 | import de.FBEditor.struct.JTextPane2;
16 |
17 | /**
18 | * Search & Replace window
19 | *
20 | */
21 | public class FindReplace extends JDialog {
22 |
23 | public FindReplace(FBEdit parent, int type) {
24 | super(parent, type != 2 ? FBEdit.getMessage("find.search") : FBEdit.getMessage("find.searchandreplace"));
25 | this.type = type;
26 | initComponents();
27 | setLocationRelativeTo(parent);
28 | setVisible(true);
29 | pane = parent.getJTextPane();
30 | }
31 |
32 | private void initComponents() {
33 | JPanel jPanel1 = new JPanel();
34 | JPanel jPanel2 = new JPanel();
35 | JPanel jPanel3 = new JPanel();
36 | JPanel jPanel4 = new JPanel();
37 | JPanel jPanel5 = new JPanel();
38 | JPanel jPanel6 = new JPanel();
39 |
40 | JLabel jLabel1 = new JLabel();
41 | JLabel jLabel2 = new JLabel();
42 |
43 | JButton jButton1 = new JButton();
44 | JButton jButton4 = new JButton();
45 | JButton jButton2 = new JButton();
46 | @SuppressWarnings("unused")
47 | JButton jButton3 = new JButton();
48 | JButton jButton5 = new JButton();
49 |
50 | TFfind = new JTextField();
51 | TFreplace = new JTextField();
52 | /*
53 | final CutAndPaste CAP = new CutAndPaste();
54 | final JPopupMenu popup = CAP.getPopupMenu();
55 |
56 | addWindowListener(new WindowAdapter() {
57 |
58 | public void windowClosing(WindowEvent evt) {
59 | closeDialog(evt);
60 | }
61 | });
62 |
63 | MouseAdapter mouseadapt = new MouseAdapter() {
64 |
65 | public void mousePressed(MouseEvent e) {
66 | if (e.isPopupTrigger()) {
67 | CAP.updateSource((JTextComponent) e.getSource());
68 | CAP.updateMenu();
69 | popup.show((Component) e.getSource(), e.getX(), e.getY());
70 | }
71 | }
72 |
73 | public void mouseReleased(MouseEvent e) {
74 | if (e.isPopupTrigger()) {
75 | CAP.updateSource((JTextComponent) e.getSource());
76 | CAP.updateMenu();
77 | popup.show((Component) e.getSource(), e.getX(), e.getY());
78 | }
79 | }
80 | };
81 |
82 | ActionListener myListener = new ActionListener() {
83 | public void actionPerformed(ActionEvent evt) {
84 | jButton1ActionPerformed();
85 | }
86 | };
87 |
88 | TFfind.addActionListener(myListener);
89 | TFreplace.addActionListener(myListener);
90 |
91 | TFreplace.addMouseListener(mouseadapt);
92 | TFfind.addMouseListener(mouseadapt);
93 | */
94 | jPanel1.setLayout(new BoxLayout(jPanel1, 1));
95 | jPanel3.setPreferredSize(new Dimension(20, 20));
96 | jLabel1.setText(FBEdit.getMessage("find.search"));
97 | jPanel3.add(jLabel1);
98 | jPanel1.add(jPanel3);
99 | jPanel4.setLayout(new FlowLayout(0));
100 | TFfind.setPreferredSize(new Dimension(150, 20));
101 | jPanel4.add(TFfind);
102 | jPanel1.add(jPanel4);
103 | jPanel5.setPreferredSize(new Dimension(20, 20));
104 | jLabel2.setText(FBEdit.getMessage("find.replace"));
105 | if (type != 2)
106 | jLabel2.setEnabled(false);
107 | jPanel5.add(jLabel2);
108 | jPanel1.add(jPanel5);
109 | jPanel6.setLayout(new FlowLayout(0));
110 | TFreplace.setPreferredSize(new Dimension(150, 20));
111 | if (type != 2)
112 | TFreplace.setEnabled(false);
113 | jPanel6.add(TFreplace);
114 | jPanel1.add(jPanel6);
115 | getContentPane().add(jPanel1, "Center");
116 | jPanel2.setLayout(new BoxLayout(jPanel2, 1));
117 | jButton1.setText(FBEdit.getMessage("find.continue"));
118 | jButton1.setMaximumSize(new Dimension(115, 26));
119 | jButton1.setPreferredSize(new Dimension(115, 26));
120 | jButton1.addActionListener(new ActionListener() {
121 |
122 | public void actionPerformed(ActionEvent evt) {
123 | findActionPerformed();
124 | }
125 | });
126 | jPanel2.add(jButton1);
127 | jButton4.setText(FBEdit.getMessage("find.searchall"));
128 | jButton4.setMaximumSize(new Dimension(115, 26));
129 | jButton4.setPreferredSize(new Dimension(115, 26));
130 | jButton4.addActionListener(new ActionListener() {
131 |
132 | public void actionPerformed(ActionEvent evt) {
133 | findAllActionPerformed();
134 | }
135 | });
136 | jPanel2.add(jButton4);
137 | jButton2.setText(FBEdit.getMessage("find.replace"));
138 | jButton2.setMaximumSize(new Dimension(115, 26));
139 | jButton2.setPreferredSize(new Dimension(115, 26));
140 | jButton2.addActionListener(new ActionListener() {
141 |
142 | public void actionPerformed(ActionEvent evt) {
143 | replaceActionPerformed();
144 | }
145 | });
146 | if (type != 2)
147 | jButton2.setEnabled(false);
148 | jPanel2.add(jButton2);
149 | /*
150 | jButton3.setText("Alle Ersetzen");
151 | jButton3.setMaximumSize(new Dimension(115, 26));
152 | jButton3.setPreferredSize(new Dimension(115, 26));
153 | jButton3.addActionListener(new ActionListener() {
154 |
155 | public void actionPerformed(ActionEvent evt) {
156 | replaceAllActionPerformed();
157 | }
158 | });
159 | if (type != 2)
160 | jButton3.setEnabled(false);
161 | jPanel2.add(jButton3);
162 | */
163 | jButton5.setText(FBEdit.getMessage("find.cancel"));
164 | jButton5.setMaximumSize(new Dimension(115, 26));
165 | jButton5.setPreferredSize(new Dimension(115, 26));
166 | jButton5.addActionListener(new ActionListener() {
167 |
168 | public void actionPerformed(ActionEvent evt) {
169 | jButton5ActionPerformed();
170 | }
171 | });
172 | jPanel2.add(jButton5);
173 | getContentPane().add(jPanel2, "East");
174 | pack();
175 | }
176 |
177 | private void findActionPerformed() {
178 | JTextPane2.findText(pane, TFfind.getText());
179 | }
180 |
181 | private void findAllActionPerformed() {
182 | JTextPane2.findAll(pane, TFfind.getText());
183 | }
184 |
185 | private void replaceActionPerformed() {
186 | JTextPane2.replaceText(pane, TFreplace.getText());
187 | }
188 |
189 | @SuppressWarnings("unused")
190 | private void replaceAllActionPerformed() {
191 | JTextPane2.replaceAll(pane, TFreplace.getText());
192 | }
193 |
194 | private void jButton5ActionPerformed() {
195 | setVisible(false);
196 | dispose();
197 | }
198 | /*
199 | private void closeDialog(WindowEvent evt) {
200 | setVisible(false);
201 | dispose();
202 | }
203 | */
204 | /* continue search on F3 */
205 | public void searchon() {
206 | findActionPerformed();
207 | }
208 |
209 | public static final int SEARCH = 1;
210 | public static final int REPLACE = 2;
211 | private int type;
212 | private static final long serialVersionUID = 1L;
213 | private JTextField TFreplace;
214 | private JTextField TFfind;
215 | private JTextPane2 pane;
216 |
217 | }
218 |
--------------------------------------------------------------------------------
/src/de/FBEditor/FritzBoxConnection.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import de.FBEditor.struct.FBFWVN;
4 | import de.FBEditor.struct.HttpPost;
5 | import de.FBEditor.struct.SIDLogin;
6 | import de.FBEditor.struct.FbQueryLua;
7 | import de.FBEditor.utils.Utils;
8 | import java.io.IOException;
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 | import java.util.regex.Matcher;
12 | import java.util.regex.Pattern; // 01.03.2014
13 | import javax.swing.JOptionPane;
14 |
15 | /**
16 | * Class holding connection information
17 | */
18 | public final class FritzBoxConnection {
19 |
20 | private boolean connected = false;
21 | private static FritzBoxFirmware firmware;
22 | @SuppressWarnings("unused")
23 | private SIDLogin sidLogin;
24 | private String postdata;
25 | private String urlstr;
26 | private String urlstr1;
27 | private String urlstr2;
28 | private String box_password;
29 | private String box_username;
30 | private static String sRetSID = "0000000000000000";
31 |
32 | public FritzBoxConnection(String box_address, String box_password,
33 | String box_username) {
34 | updateURLstr(box_address);
35 | try {
36 | this.box_password = box_password;
37 | this.box_username = box_username;
38 |
39 | sidLogin = new SIDLogin();
40 |
41 | if (Utils.checkhost(box_address)) {
42 | getAccessMethod();
43 | }
44 | } catch (IOException ex) {
45 | Logger.getLogger(FritzBoxConnection.class.getName()).log(
46 | Level.SEVERE, null, ex);
47 | }
48 | }
49 |
50 | private void updateURLstr(String boxAddress) {
51 | urlstr = "http://" + boxAddress + "/cgi-bin/webcm";
52 | urlstr1 = urlstr;
53 | urlstr2 = "http://" + boxAddress;
54 | }
55 |
56 | void getAccessMethod() {
57 | String data;
58 | String language = "de";
59 | @SuppressWarnings("unused")
60 | Boolean speedport = false;
61 | boolean detected = false;
62 |
63 | // SIDLogin.Login("", urlstr1, box_password, box_username, sRetSID);
64 | System.out.println("LoginLua: " + FBEdit.getInstance().getBoxLoginLuaState());
65 | if (FBEdit.getInstance().getBoxLoginLuaState().equalsIgnoreCase("true")) { // 25.06.2018
66 | SIDLogin.LoginLua("", urlstr1, box_password, box_username, sRetSID);
67 | } else {
68 | SIDLogin.Login("", urlstr1, box_password, box_username, sRetSID);
69 | }
70 | sRetSID = SIDLogin.getSessionId();
71 |
72 | FBFWVN fbfwvn = new FBFWVN(getFirmwareStatus());
73 | // FBFWVN fbfwvn = new
74 | // FBFWVN("FRITZ!Box Fon WLAN 7362 SL-B-101100-000008-630046-320710-787902-1310601-12345-avm-de");
75 | // 15.04.2015
76 | // FBFWVN("FRITZ!Box Fon WLAN 7390-B-010702-000024-006117-745743-147902-overwrite feature CONFIG_WLAN_HOTSPOT=y-840623-overwrite feature CONFIG_WLAN_HOTSPOT=y-29836-avm");
77 |
78 | if (SIDLogin.isSidLogin()) {
79 | if (fbfwvn.isOK()) {
80 | detected = true;
81 | } else {
82 | // 15.04.2015
83 | if (sRetSID != "0000000000000000") detected = true;
84 | }
85 |
86 | } else if (SIDLogin.isLogin()) {
87 | detected = true;
88 | }
89 |
90 | if (detected) {
91 | connected = true;
92 | }
93 |
94 | if (!detected) {
95 | JOptionPane.showMessageDialog(FBEdit.getInstance().getframe(),
96 | FBEdit.getMessage("utils.read_error"),
97 | FBEdit.getMessage("main.error"), 0);
98 | return;
99 | }
100 |
101 | String FritzboxName = "", boxtypeString = "", majorFirmwareVersion = "", minorFirmwareVersion = "", modFirmwareVersion = "";
102 |
103 | if (fbfwvn.isOK()) {
104 |
105 | FritzboxName = fbfwvn.getFritzbox();
106 | boxtypeString = fbfwvn.getBoxTypeFBFWVN();
107 | majorFirmwareVersion = fbfwvn.getMajorFBFWVN();
108 | minorFirmwareVersion = fbfwvn.getMinorFBFWVN();
109 | modFirmwareVersion = fbfwvn.getModFBFWVN();
110 |
111 | // language != "de" 01.03.2014
112 | if (fbfwvn.isFritzboxLanguage()) {
113 | language = fbfwvn.getFritzboxLanguage().toLowerCase();
114 | }
115 |
116 | } else {
117 |
118 | HttpPost http = new HttpPost();
119 | boolean isQueryOld = false;
120 | boolean isQueryLua = false;
121 | String url = urlstr;
122 | String sLink;
123 | String sRetQueryOld;
124 | String sRetQueryNew;
125 | String sRetQueryLua;
126 | postdata = "sid=" + sRetSID + "&"
127 | + "getpage=../html/query.txt&var:cnt=1" + "&var:n" + "0"
128 | + "=" + "logic:status/nspver";
129 | sRetQueryOld = http.Post2(url, postdata);
130 | postdata = "sid=" + sRetSID + "&"
131 | + "getpage=../html/query.txt&var:cnt=1" + "&var:n[" + "0"
132 | + "]=" + "logic:status/nspver";
133 | sRetQueryNew = http.Post2(url, postdata);
134 |
135 | if (sRetQueryOld.length() > sRetQueryNew.length()) {
136 | isQueryOld = true;
137 | data = sRetQueryOld;
138 | } else {
139 | data = sRetQueryNew;
140 | }
141 |
142 | if (sRetQueryOld.length() == sRetQueryNew.length()) {
143 | sLink = "/query.lua" + "?" + "sid=" + sRetSID + "&nspver=" + "logic:status/nspver";
144 | sRetQueryLua = http.Post(urlstr2 + sLink, "");
145 | int nRet = 0;
146 | nRet = FbQueryLua.sQueryLuaAll(sRetQueryLua, "nspver=logic:status/nspver", "nspver", "", 1);
147 | if (nRet == 1) {
148 | data = FbQueryLua.sQueryLuaAllsRetValue();
149 | sRetQueryLua = data;
150 | isQueryLua = true;
151 | } else {
152 | data = "0.0.0";
153 | }
154 | System.out.println(urlstr2 + sLink);
155 | System.out.println("QueryLua: " + isQueryLua + " " + sRetQueryLua.replace("\n", ""));
156 | } else {
157 | System.out.println(url);
158 | }
159 |
160 | System.out.println("QueryOld: " + isQueryOld + " "
161 | + sRetQueryOld.replace("\n", "") + " " + sRetQueryNew.replace("\n", ""));
162 | // data = "131.06.55-12345"; // Test 01.03.2014
163 | // data = "33.04.57-12345"; // Test 01.03.2014
164 | Pattern normalFirmware;
165 | // normalFirmware = Pattern.compile("([0-9]*).([0-9]*).([0-9]*)");
166 | normalFirmware = Pattern
167 | .compile("([0-9]*).([0-9]*).([0-9]*)[|-]?([^[0-9]<]*)"); // 01.03.2014 mit mod
168 |
169 | Matcher m = normalFirmware.matcher(data);
170 | if (m.find()) {
171 | boxtypeString = m.group(1);
172 | majorFirmwareVersion = m.group(2);
173 | minorFirmwareVersion = m.group(3);
174 |
175 | // modFirmwareVersion = m.group(4).trim(); // Fehler nicht vorhanden
176 | modFirmwareVersion = ""; // erkennt sonst die Box 701/900 nicht
177 |
178 | try { // Test 01.03.2014
179 | modFirmwareVersion = m.group(4);
180 | System.out.println("modFirmwareVersion: " + m.group(4));
181 | } catch (Exception e) {
182 | // TODO Auto-generated catch block
183 | //e.printStackTrace();
184 | System.out.println("error modFirmwareVersion: "
185 | + m.group(4));
186 |
187 | }
188 | }
189 |
190 | }
191 | firmware = new FritzBoxFirmware(FritzboxName, boxtypeString,
192 | majorFirmwareVersion, minorFirmwareVersion, modFirmwareVersion,
193 | language);
194 |
195 | System.out.println("Debug boxtype: " + boxtypeString);
196 |
197 | }
198 |
199 | public boolean reconnect(String box_address, String box_password,
200 | String box_username) {
201 | boolean result = false;
202 | connected = false;
203 | try {
204 | updateURLstr(box_address);
205 | this.box_password = box_password;
206 | this.box_username = box_username;
207 | if (Utils.checkhost(box_address)) {
208 | sRetSID = SIDLogin.getSessionId();
209 | if (FBEdit.getInstance().getBoxLoginLuaState().equalsIgnoreCase("true")) { // 25.06.2018
210 | SIDLogin.LoginLua("", urlstr1, box_password, box_username, sRetSID);
211 | } else {
212 | SIDLogin.Login("", urlstr1, box_password, box_username, sRetSID);
213 | }
214 | sRetSID = SIDLogin.getSessionId();
215 | if (SIDLogin.isSidLogin()) {
216 | result = true;
217 | connected = true;
218 | }
219 | }
220 | } catch (IOException ex) {
221 | Logger.getLogger(FritzBoxConnection.class.getName()).log(
222 | Level.SEVERE, null, ex);
223 | }
224 | return result;
225 | }
226 |
227 | public boolean isConnected() {
228 | return connected;
229 | }
230 |
231 | public FritzBoxFirmware getFirmware() {
232 | return firmware;
233 | }
234 |
235 | public String getFirmwareStatus() {
236 | HttpPost http = new HttpPost();
237 | String url = (new StringBuilder("http://"))
238 | .append(FBEdit.getInstance().getbox_address())
239 | .append("/cgi-bin/system_status").toString();
240 | String sFBFW_Status = http.Post(url, "");
241 | return sFBFW_Status;
242 | }
243 | }
244 |
--------------------------------------------------------------------------------
/src/de/FBEditor/FritzBoxFirmware.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 |
4 | /**
5 | * Class modelling firmware and box information
6 | *
7 | */
8 | public class FritzBoxFirmware {
9 |
10 | private String FritzboxName;
11 | private int boxtype; // Muss Integer sein wegen neuen Firmware Typ > 127
12 | private byte majorFirmwareVersion;
13 | private byte minorFirmwareVersion;
14 | private String modFirmwareVersion;
15 | @SuppressWarnings("unused")
16 | private String language;
17 |
18 | /**
19 | * Firmware Constructor using Strings
20 | *
21 | * @param FritzboxName
22 | * @param boxtype
23 | * @param majorFirmwareVersion
24 | * @param minorFirmwareVersion
25 | * @param modFirmwareVersion
26 | * @param language
27 | */
28 | public FritzBoxFirmware(String FritzboxName, String boxtype,
29 | String majorFirmwareVersion, String minorFirmwareVersion,
30 | String modFirmwareVersion, String language) {
31 | this.FritzboxName = FritzboxName;
32 | this.boxtype = Integer.parseInt(boxtype);
33 | this.majorFirmwareVersion = Byte.parseByte(majorFirmwareVersion);
34 | this.minorFirmwareVersion = Byte.parseByte(minorFirmwareVersion);
35 | this.modFirmwareVersion = modFirmwareVersion;
36 | this.language = language;
37 | }
38 |
39 | public String getFritzboxName() {
40 | return FritzboxName;
41 | }
42 |
43 | /**
44 | * @return Returns the boxtype.
45 | */
46 | public final int getBoxType() {
47 | return boxtype;
48 | }
49 |
50 | /**
51 | * @return Returns the majorFirmwareVersion.
52 | */
53 | public final byte getMajorFirmwareVersion() {
54 | return majorFirmwareVersion;
55 | }
56 |
57 | /**
58 | * @return Returns the minorFirmwareVersion.
59 | */
60 | public final byte getMinorFirmwareVersion() {
61 | return minorFirmwareVersion;
62 | }
63 |
64 | /**
65 | * @return Returns the minorFirmwareVersion.
66 | */
67 | public final String getModFirmwareVersion() {
68 | return modFirmwareVersion;
69 | }
70 |
71 | /**
72 | * @return Returns the majorFirmwareVersion.
73 | */
74 | public final String getFirmwareVersion() {
75 | String boxtypeStr = Integer.toString(boxtype);
76 | String majorStr = Byte.toString(majorFirmwareVersion);
77 | String minorStr = Byte.toString(minorFirmwareVersion);
78 | if (boxtypeStr.length() == 1) {
79 | boxtypeStr = "0" + boxtypeStr;
80 | }
81 | if (majorStr.length() == 1) {
82 | majorStr = "0" + majorStr;
83 | }
84 | if (minorStr.length() == 1) {
85 | minorStr = "0" + minorStr;
86 | }
87 | return boxtypeStr + "." + majorStr + "." + minorStr; // +
88 | // modFirmwareVersion;
89 | }
90 |
91 | public String getBoxName() {
92 |
93 | System.out.println( "Debug FritzBoxFirmware: " + FritzboxName + " -> " + boxtype );
94 |
95 | if ((FritzboxName.length() > 0) && (boxtype > 0)) {
96 | return FritzboxName;
97 | } else {
98 | switch (boxtype) {
99 | case 5:
100 | return "FRITZ!Box";
101 | case 6:
102 | return "FRITZ!Box Fon";
103 | case 8:
104 | return "FRITZ!Box Fon WLAN";
105 | case 9:
106 | return "Fritz!Box SL WLAN (FRITZ!Box 3020)";
107 | case 10:
108 | return "Fritz!Box SL";
109 | case 11:
110 | return "FRITZ!Box Fon ata";
111 | case 12:
112 | return "FRITZ!Box 5050";
113 | case 13:
114 | return "FRITZ!Box Fon Mini VoIP";
115 | case 14:
116 | return "FRITZ!Box 7050";
117 | case 15:
118 | return "Eumex 300 IP";
119 | case 16:
120 | return "FRITZ!Box 3050";
121 | case 17:
122 | return "FRITZ!Box 2030";
123 | case 19:
124 | return "FRITZ!Box 3070";
125 | case 20:
126 | return "FRITZ!Box 2070";
127 | case 21:
128 | return "FRITZ!Box 3030";
129 | case 23:
130 | return "FRITZ!Box 5010";
131 | case 25:
132 | return "FRITZ!Box 5012";
133 | case 27:
134 | return "T-Com Sinus W 500V";
135 | case 28:
136 | return "Speedport W501V";
137 | case 29:
138 | return "FRITZ!Box 7170 (SL) V1/V2";
139 | case 30:
140 | return "FRITZ!Box 7140";
141 | case 33:
142 | return "Speedport W701V";
143 | case 34:
144 | return "Speedport W900V";
145 | case 36:
146 | return "FRITZ!Box VoIP Gateway 5188";
147 | case 38:
148 | return "FRITZ!Box 7150";
149 | case 39:
150 | return "FRITZ!Box Fon WLAN 7140 Annex A";
151 | case 40:
152 | return "FRITZ!Box 7141";
153 | case 43:
154 | return "FRITZ!Box 5140";
155 | case 44:
156 | return "FRITZ!Box 3130";
157 | case 45:
158 | return "FRITZ!Box 2031";
159 | case 48:
160 | return "FRITZ!Box Fon 5010 Annex A";
161 | case 49:
162 | return "FRITZ!Box 3170";
163 | case 50:
164 | return "FRITZ!Box 3131";
165 | case 51:
166 | return "FRITZ!Box 2170";
167 | case 54:
168 | return "FRITZ!Box 7270 V1/V2";
169 | case 55:
170 | return "FRITZ!Media 8020/8040";
171 | case 56:
172 | return "FRITZ!Box Fon 5124";
173 | case 57:
174 | return "FRITZ!Box Fon 5124 Annex A";
175 | case 58:
176 | return "FRITZ!Box 7170 (CH-AT-Edition)";
177 | case 60:
178 | return "FRITZ!Box 7113";
179 | case 62:
180 | return "Alice IAD 5130";
181 | case 63:
182 | return "FRITZ!Box 2110";
183 | case 64:
184 | return "Speedport W721V";
185 | case 65:
186 | return "Speedport W920V";
187 | case 66:
188 | return "Speedport W503V Typ A (congstar komplett Box)";
189 | case 67:
190 | return "FRITZ!Box 3270";
191 | case 68:
192 | return "FRITZ!WLAN Repeater N/G";
193 | case 73:
194 | return "FRITZ!Box 7240";
195 | case 74:
196 | return "FRITZ!Box 7270 V3";
197 | case 75:
198 | return "FRITZ!Box 7570";
199 | case 80:
200 | return "Speedport W722V Typ A";
201 | case 81:
202 | return "FRITZ!Box 7570 HN";
203 | case 83:
204 | return "FRITZ!Box Fon 5113 Annex A";
205 | case 84:
206 | return "FRITZ!Box 7390";
207 | case 85:
208 | return "FRITZ!Box 6360 Cable";
209 | case 87:
210 | return "FRITZ!Box 7112";
211 | case 90:
212 | return "FRITZ!Box Fon WLAN 7113 Annex A";
213 | case 91:
214 | return "FRITZ!Media 8260";
215 | case 93:
216 | return "Speedport W501V";
217 | case 96:
218 | return "FRITZ!Box 3270 V3";
219 | case 99:
220 | return "FRITZ!Box 7340";
221 | case 100:
222 | return "FRITZ!Box 7320";
223 | case 101:
224 | return "FRITZ!Box Fon WLAN Speedport W701V (FRITZ!WLAN Repeater 300E)";
225 | case 102:
226 | return "FRITZ!Box Fon WLAN Speedport W900V (IAD WLAN 3331)";
227 | case 103:
228 | return "FRITZ!Box 3370";
229 | case 104:
230 | return "FRITZ!Box 6320 Cable";
231 | case 105:
232 | return "FRITZ!Box 6840 LTE";
233 | case 107:
234 | return "FRITZ!Box 7330";
235 | case 108:
236 | return "FRITZ!Box 6810 LTE";
237 | case 109:
238 | return "FRITZ!Box 7360 SL";
239 | case 110:
240 | return "FRITZ!Box 6320 V2 Cable";
241 | case 111:
242 | return "FRITZ!Box 7360 V1";
243 | case 113:
244 | return "FRITZ!Box 7490";
245 | case 115:
246 | return "FRITZ!Box 6340 Cable";
247 | case 116:
248 | return "FRITZ!Box 7330 SL";
249 | case 117:
250 | return "FRITZ!Box 7312";
251 | case 118:
252 | return "FRITZ!Powerline 546E";
253 | case 119:
254 | return "FRITZ!Box 7369";
255 | case 120:
256 | return "FRITZ!Box 7272";
257 | case 121:
258 | return "FRITZ!Box 3390";
259 | case 122:
260 | return "FRITZ!WLAN Repeater 310 A";
261 | case 123:
262 | return "FRITZ!Box 6842 LTE";
263 | case 124:
264 | return "FRITZ!Box 7360 V2";
265 | case 125:
266 | return "FRITZ!Box 3270 V3 (IT-Edition)";
267 | case 126:
268 | return "FRITZ!Box 3272";
269 | case 128:
270 | return "FRITZ!WLAN Repeater 450E";
271 | case 129:
272 | return "FRITZ!Powerline 540E";
273 | case 131:
274 | return "FRITZ!Box 7362 SL";
275 | case 133:
276 | return "FRITZ!WLAN Repeater DVB-C";
277 | case 134:
278 | return "FRITZ!WLAN Repeater 1750E";
279 | case 137:
280 | return "FRITZ!Box 7412";
281 | case 140:
282 | return "FRITZ!Box 3490";
283 | case 141:
284 | return "FRITZ!Box 6490 Cable";
285 | case 142:
286 | return "FRITZ!Box 6820 LTE";
287 | case 143:
288 | return "FRITZ!WLAN Repeater 310 B";
289 | case 144:
290 | return "FRITZ!WLAN Repeater 1160";
291 | case 146:
292 | return "FRITZ!Box 7430";
293 | case 147:
294 | return "FRITZ!Box 4020";
295 | case 148:
296 | return "FRITZ!Box 6590 Cable";
297 | case 149:
298 | return "FRITZ!Box 7560";
299 | case 150:
300 | return "FRITZ!Powerline 1240E";
301 | case 151:
302 | return "FRITZ!Box 5490";
303 | case 152:
304 | return "FRITZ!Box 7581 (International)";
305 | case 153:
306 | return "FRITZ!Box 7580";
307 | case 154:
308 | return "FRITZ!Box 7590";
309 | case 155:
310 | return "FRITZ!Box 4040";
311 | case 156:
312 | return "FRITZ!Box 7582";
313 | case 157:
314 | return "FRITZ!Powerline 1260E";
315 | case 159:
316 | return "FRITZ!Box 6430 Cable";
317 | case 161:
318 | return "FRITZ!Box 6591 Cable";
319 | case 162:
320 | return "FRITZ!Box 6890 LTE";
321 | case 164:
322 | return "FRITZ!Box 7530";
323 | case 175:
324 | return "FRITZ!Box 7520";
325 | default:
326 | return "unknown";
327 | }
328 | }
329 | }
330 | }
331 |
--------------------------------------------------------------------------------
/src/de/FBEditor/ImportData.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.IOException;
5 |
6 | import javax.swing.JOptionPane;
7 |
8 | import org.apache.commons.httpclient.HttpClient;
9 | import org.apache.commons.httpclient.methods.PostMethod;
10 | import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
11 | import org.apache.commons.httpclient.methods.multipart.Part;
12 |
13 | import de.FBEditor.struct.SIDLogin; // 01.03.2014
14 | import de.FBEditor.utils.StringPartNoTransferEncoding;
15 |
16 | /**
17 | * Import configuration from FBox
18 | *
19 | */
20 | public class ImportData implements Runnable {
21 |
22 | public ImportData() {
23 | }
24 |
25 | public void run() {
26 | String data = "";
27 | int statusCode = 0;
28 | String url = (new StringBuilder("http://"))
29 | .append(FBEdit.getInstance().getbox_address())
30 | .append("/cgi-bin/firmwarecfg").toString();
31 | PostMethod mPost = new PostMethod(url);
32 |
33 | // Kennwort der Sicherungsdatei
34 | String ConfigImExPwd = "";
35 | /*
36 | String box_ConfigImExPwd = FBEdit.getInstance().getbox_ConfigImExPwd();
37 | System.out.println("box.ConfigImExPwd: " + box_ConfigImExPwd);
38 |
39 | if ( !"".equals(box_ConfigImExPwd) ) {
40 | // Hier kann man ein PopUp Dialog verwenden
41 | // mit der Frage, mit oder ohne Kennwort Lesen
42 |
43 | FBEdit.getInstance().getConfigImExPwd(false);
44 |
45 | if ( FBEdit.isConfigImExPwdOk() == true ) {
46 | box_ConfigImExPwd = FBEdit.getInstance().getbox_ConfigImExPwd();
47 | // ConfigImExPwd = ""; // Abbrechen -> ohne Kennwort
48 | ConfigImExPwd = box_ConfigImExPwd; // OK -> mit Kennwort
49 | }
50 | System.out.println("ConfigImExPwd: " + ConfigImExPwd + " -> " + FBEdit.isConfigImExPwdOk());
51 | }
52 | */
53 | try {
54 | String sid = SIDLogin.getSessionId();
55 |
56 | HttpClient client = new HttpClient();
57 | client.getHttpConnectionManager().getParams()
58 | .setConnectionTimeout(8000);
59 |
60 | Part[] parts = null;
61 | if (SIDLogin.isSidLogin()) {
62 | // with session id
63 | parts = new Part[3];
64 | parts[0] = new StringPartNoTransferEncoding("sid", sid);
65 | //parts[1] = new StringPartNoTransferEncoding(
66 | // "ImportExportPassword", "");
67 | parts[1] = new StringPartNoTransferEncoding(
68 | "ImportExportPassword", ConfigImExPwd);
69 | parts[2] = new StringPartNoTransferEncoding("ConfigExport", "");
70 | } else {
71 | // old style, no session id
72 | parts = new Part[2];
73 | //parts[0] = new StringPartNoTransferEncoding(
74 | // "ImportExportPassword", "");
75 | parts[0] = new StringPartNoTransferEncoding(
76 | "ImportExportPassword", ConfigImExPwd);
77 | parts[1] = new StringPartNoTransferEncoding("ConfigExport", "");
78 | }
79 |
80 | mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost
81 | .getParams()));
82 |
83 | statusCode = client.executeMethod(mPost);
84 | BufferedInputStream bis = new BufferedInputStream(
85 | mPost.getResponseBodyAsStream());
86 | byte buf[] = new byte[4096];
87 | StringBuffer sb = new StringBuffer();
88 | int len;
89 | while ((len = bis.read(buf)) > 0)
90 | sb.append(new String(buf, 0, len));
91 | data = sb.toString();
92 | } catch (IOException e) {
93 | e.printStackTrace();
94 | } finally {
95 | mPost.releaseConnection();
96 | }
97 | if (!(statusCode == 200 && checkResponse(data))) {
98 |
99 | JOptionPane.showMessageDialog(FBEdit.getInstance().getframe(),
100 | FBEdit.getMessage("utils.read_error") + "\n" + upnp(),
101 | FBEdit.getMessage("main.error"), 0);
102 |
103 | // data = FBEdit.getMessage("main.error") + "!";
104 | data = upnp(); // 27.04.2018
105 |
106 | // try to reconnect
107 | FBEdit.makeNewConnection(false);
108 | }
109 | // Put Export into Textpane
110 | FBEdit.getInstance().setData(data);
111 | }
112 |
113 | private boolean checkResponse(String data) {
114 | return data.startsWith("****");
115 | }
116 |
117 | private String upnp() { // 27.04.2018
118 |
119 | String s2FA = "";
120 |
121 | s2FA = FBEdit.getInstance().getupnp2FAsid();
122 |
123 | if (!s2FA.equals("")) {
124 | return s2FA;
125 | }
126 |
127 | // return "sid=" + UPNPUtils.getSIDUPNP() + "\n" + "2FA -> " + UPNPUtils.get2FAUPNP() + "\n";
128 | return FBEdit.getMessage("main.error") + "!";
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/de/FBEditor/MyMenu.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor;
2 |
3 | import java.awt.FlowLayout;
4 |
5 | import javax.swing.BorderFactory;
6 | import javax.swing.JCheckBoxMenuItem;
7 | import javax.swing.JLabel;
8 | import javax.swing.JMenu;
9 | import javax.swing.JMenuItem;
10 | import javax.swing.JPanel;
11 | import javax.swing.text.Element;
12 |
13 | import de.FBEditor.struct.JTextPane2;
14 |
15 | /**
16 | * Class implementing the menu items
17 | *
18 | */
19 | public class MyMenu {
20 |
21 | public MyMenu(FBEdit fbedit) {
22 | this.fbedit = fbedit;
23 | this.action = fbedit.getActionListener();
24 |
25 | }
26 |
27 | JMenu createFileMenu() {
28 | JMenu ret = new JMenu(FBEdit.getMessage("menu.file"));
29 | ret.setMnemonic('D');
30 | JMenuItem mi = new JMenuItem(FBEdit.getMessage("menu.new"), 78);
31 | fbedit.setCtrlAccelerator(mi, 'N');
32 | mi.setActionCommand("new");
33 | mi.addActionListener(action);
34 | ret.add(mi);
35 | mi = new JMenuItem(FBEdit.getMessage("menu.open"), 102);
36 | fbedit.setCtrlAccelerator(mi, 'O');
37 | mi.setActionCommand("open");
38 | mi.addActionListener(action);
39 | ret.add(mi);
40 | exportcfg = new JMenuItem(FBEdit.getMessage("menu.config_read"), 115);
41 | fbedit.setCtrlAccelerator(exportcfg, 'E');
42 | exportcfg.setActionCommand("config_read");
43 | exportcfg.addActionListener(action);
44 | exportcfg.setEnabled(false);
45 | ret.add(exportcfg);
46 | ret.addSeparator();
47 | mi = new JMenuItem(FBEdit.getMessage("menu.config_save"), 112);
48 | fbedit.setCtrlAccelerator(mi, 'S');
49 | mi.setActionCommand("save");
50 | mi.addActionListener(action);
51 | ret.add(mi);
52 | importcfg = new JMenuItem(FBEdit.getMessage("menu.config_write"), 119);
53 | importcfg.setActionCommand("config_write");
54 | importcfg.addActionListener(action);
55 | importcfg.setEnabled(false);
56 | ret.add(importcfg);
57 | ret.addSeparator();
58 | reconnect = new JMenuItem(FBEdit.getMessage("menu.reconnect"));
59 | reconnect.setActionCommand("reconnect");
60 | reconnect.addActionListener(action);
61 | reconnect.setEnabled(false);
62 | ret.add(reconnect);
63 | ret.addSeparator();
64 | mi = new JMenuItem(FBEdit.getMessage("menu.exit"), 66);
65 | mi.setActionCommand("exit");
66 | mi.addActionListener(action);
67 | ret.add(mi);
68 | return ret;
69 | }
70 |
71 | JMenu createEditMenu() {
72 | JMenu ret = new JMenu(FBEdit.getMessage("menu.edit"));
73 | ret.setMnemonic('B');
74 | ret.addMenuListener(new EditMenuListener(fbedit));
75 | undo = new JMenuItem(FBEdit.getMessage("menu.revert"), 82);
76 | fbedit.setCtrlAccelerator(undo, 'Z');
77 | undo.setEnabled(false);
78 | undo.setActionCommand("revert");
79 | undo.addActionListener(action);
80 | ret.add(undo);
81 | redo = new JMenuItem(FBEdit.getMessage("menu.restore"), 87);
82 | fbedit.setCtrlAccelerator(redo, 'Y');
83 | redo.setActionCommand("restore");
84 | redo.addActionListener(action);
85 | redo.setEnabled(false);
86 | ret.add(redo);
87 | ret.addSeparator();
88 | cut = new JMenuItem(FBEdit.getMessage("menu.cut"), 117);
89 | fbedit.setCtrlAccelerator(cut, 'X');
90 | cut.setActionCommand("cut");
91 | cut.addActionListener(action);
92 | cut.setEnabled(false);
93 | ret.add(cut);
94 | copy = new JMenuItem(FBEdit.getMessage("menu.copy"), 75);
95 | fbedit.setCtrlAccelerator(copy, 'C');
96 | copy.setActionCommand("copy");
97 | copy.addActionListener(action);
98 | copy.setEnabled(false);
99 | ret.add(copy);
100 | insert = new JMenuItem(FBEdit.getMessage("menu.insert"), 105);
101 | fbedit.setCtrlAccelerator(insert, 'V');
102 | insert.setActionCommand("insert");
103 | insert.addActionListener(action);
104 | insert.setEnabled(false);
105 | ret.add(insert);
106 | delete = new JMenuItem(FBEdit.getMessage("menu.delete"), 76);
107 | // fbedit.setCtrlAccelerator(delete, 'L');
108 | delete.setActionCommand("delete");
109 | delete.addActionListener(action);
110 | delete.setEnabled(false);
111 | ret.add(delete);
112 | ret.addSeparator();
113 | JMenuItem mi = new JMenuItem(FBEdit.getMessage("menu.search"), 83);
114 | fbedit.setCtrlAccelerator(mi, 'F');
115 | mi.setActionCommand("search");
116 | mi.addActionListener(action);
117 | ret.add(mi);
118 | mi = new JMenuItem(FBEdit.getMessage("menu.replace"), 69);
119 | fbedit.setCtrlAccelerator(mi, 'R');
120 | mi.setActionCommand("replace");
121 | mi.addActionListener(action);
122 | ret.add(mi);
123 | return ret;
124 | }
125 |
126 | JMenu createHelpMenu() {
127 | JMenu ret = new JMenu(FBEdit.getMessage("menu.help"));
128 | ret.setMnemonic('H');
129 | hardmenu = new JMenuItem(FBEdit.getMessage("menu.boxinfo"), 72);
130 | hardmenu.setEnabled(false);
131 | ret.add(hardmenu);
132 | hardmenu.setActionCommand("boxinfo");
133 | hardmenu.addActionListener(action);
134 | JMenuItem mi = new JMenuItem(FBEdit.getMessage("menu.about"), 98);
135 | ret.add(mi);
136 | mi.setActionCommand("about");
137 | mi.addActionListener(action);
138 | return ret;
139 | }
140 |
141 | JMenu createConfigMenu() {
142 | JMenu ret = new JMenu(FBEdit.getMessage("menu.settings"));
143 | ret.setMnemonic('B');
144 | JMenuItem mi = new JMenuItem(FBEdit.getMessage("menu.host_ip"), 73);
145 | fbedit.setCtrlAccelerator(mi, 'I');
146 | mi.setActionCommand("host_ip");
147 | mi.addActionListener(action);
148 | ret.add(mi);
149 | mi = new JMenuItem(FBEdit.getMessage("menu.password"), 80);
150 | fbedit.setCtrlAccelerator(mi, 'P');
151 | mi.setActionCommand("password");
152 | mi.addActionListener(action);
153 | ret.add(mi);
154 | mi = new JMenuItem(FBEdit.getMessage("menu.username"), 85);
155 | fbedit.setCtrlAccelerator(mi, 'U');
156 | mi.setActionCommand("username");
157 | mi.addActionListener(action);
158 | ret.add(mi);
159 | /*
160 | mi = new JMenuItem(FBEdit.getMessage("menu.configimexpwd"), 67);
161 | // fbedit.setCtrlAccelerator(mi, 'C');
162 | mi.setActionCommand("configimexpwd");
163 | mi.addActionListener(action);
164 | ret.add(mi);
165 | */
166 | // 25.06.2018
167 | box_login_lua = new JCheckBoxMenuItem(FBEdit.getMessage("box.login_lua"), Boolean.parseBoolean(fbedit.getBoxLoginLuaState()));
168 | box_login_lua.setActionCommand("box_login_lua");
169 | box_login_lua.addActionListener(action);
170 | ret.add(box_login_lua);
171 | readOnStartup = new JCheckBoxMenuItem(FBEdit.getMessage("menu.config_auto_read"), Boolean.parseBoolean(fbedit.getRASstate()));
172 | readOnStartup.setActionCommand("config_auto_read");
173 | readOnStartup.addActionListener(action);
174 | ret.add(readOnStartup);
175 | NoChecks = new JCheckBoxMenuItem(FBEdit.getMessage("menu.nochecks"), Boolean.parseBoolean(fbedit.getNoChecksState()));
176 | NoChecks.setActionCommand("nochecks");
177 | NoChecks.addActionListener(action);
178 | // Disable NoChecks because it doesn't work at the moment
179 | // NoChecks.setEnabled(false); // 17.02.2014
180 | ret.add(NoChecks);
181 | // 25.06.2018
182 | ProgramStartDialog = new JCheckBoxMenuItem(FBEdit.getMessage("menu.program_start_dialog"), Boolean.parseBoolean(fbedit.getProgramStartDialogState()));
183 | ProgramStartDialog.setActionCommand("program_start_dialog");
184 | ProgramStartDialog.addActionListener(action);
185 | ret.add(ProgramStartDialog);
186 | return ret;
187 | }
188 |
189 | JPanel createStatusBar() {
190 | statusMsg = new JLabel(" ");
191 | JPanel panel = new JPanel();
192 | panel.setLayout(new FlowLayout(2));
193 | panel.add(statusMsg);
194 | panel.setBorder(BorderFactory.createEtchedBorder());
195 | return panel;
196 | }
197 |
198 | void setstatusMsg(JTextPane2 pane2) {
199 | int off = pane2.getCaretPosition();
200 | Element map = pane2.getDocument().getDefaultRootElement();
201 | int currLine = map.getElementIndex(off);
202 | int numLines = map.getElementCount();
203 | statusMsg.setText(' ' + FBEdit.getMessage("menu.line") + " " + (currLine + 1) + " / " + numLines);
204 | }
205 |
206 | JMenuItem undo;
207 | JMenuItem redo;
208 | JMenuItem exportcfg;
209 | JMenuItem importcfg;
210 | JMenuItem copy;
211 | JMenuItem cut;
212 | JMenuItem insert;
213 | JMenuItem delete;
214 | JMenuItem hardmenu;
215 | JMenuItem reconnect;
216 | JCheckBoxMenuItem box_login_lua; // 25.06.2018
217 | JCheckBoxMenuItem readOnStartup;
218 | JCheckBoxMenuItem NoChecks;
219 | JCheckBoxMenuItem ProgramStartDialog; // 25.06.2018
220 | JLabel statusMsg;
221 | private ActionListen action;
222 | private FBEdit fbedit;
223 | }
224 |
--------------------------------------------------------------------------------
/src/de/FBEditor/exceptions/InvalidFirmwareException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: InvalidFirmwareException.java,v 1.3 2009/01/24 11:01:13 robotniko Exp $
3 | *
4 | * Created on 10.04.2005
5 | */
6 |
7 | package de.FBEditor.exceptions;
8 |
9 | /**
10 | * thrown when a firmware object is invalid
11 | *
12 | * @author Arno Willig
13 | *
14 | */
15 | public class InvalidFirmwareException extends Exception {
16 | private static final long serialVersionUID = 1;
17 |
18 | public InvalidFirmwareException() {
19 | super();
20 | }
21 |
22 | public InvalidFirmwareException(final String param) {
23 | super(param);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/de/FBEditor/exceptions/WrongPasswordException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: WrongPasswordException.java,v 1.4 2009/02/23 13:57:40 robotniko Exp $
3 | *
4 | * Created on 10.04.2005
5 | */
6 |
7 | package de.FBEditor.exceptions;
8 |
9 | import javax.swing.JOptionPane;
10 |
11 | import de.FBEditor.FBEdit;
12 |
13 | /**
14 | * thrown when the web admin password of the fritz box is invalid
15 | * @author Arno Willig
16 | *
17 | */
18 |
19 | public class WrongPasswordException extends Exception {
20 | private static final long serialVersionUID = 1;
21 |
22 | private int waitSeconds = 0;
23 |
24 | private String affectedBox = "";
25 |
26 | public WrongPasswordException() {
27 | super();
28 | passwordWrongMessage();
29 | }
30 |
31 | public WrongPasswordException(final String affectedBox, final String param, final int waitSeconds) {
32 | super(param);
33 | passwordWrongMessage();
34 | this.waitSeconds = waitSeconds;
35 | this.affectedBox = affectedBox;
36 | }
37 |
38 | private void passwordWrongMessage() {
39 | JOptionPane.showMessageDialog(FBEdit.getInstance().getframe(), "Password falsch!", "Fehler", 0);
40 | }
41 |
42 | public int getRetryTime()
43 | {
44 | return waitSeconds;
45 | }
46 |
47 | public String getAffectedBox()
48 | {
49 | return affectedBox;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/de/FBEditor/font/Consola.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olistudent/FBEditor/2732f261e1448ad7135f5da818050fc7760eaa32/src/de/FBEditor/font/Consola.ttf
--------------------------------------------------------------------------------
/src/de/FBEditor/simpletests/NewChallengeTest.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.simpletests;
2 |
3 | import de.FBEditor.struct.SIDLogin;
4 | import de.FBEditor.utils.Debug;
5 |
6 | public class NewChallengeTest {
7 | private static String sRetSID = "0000000000000000";
8 |
9 | public static void main(String[] args) {
10 | // final String urlstr = "http://192.168.178.1:80/cgi-bin/webcm"; //$NON-NLS-1$, //$NON-NLS-2$
11 | final String urlstr = "http://fritz.box:80/cgi-bin/webcm"; //$NON-NLS-1$, //$NON-NLS-2$
12 | final String box_user = "fritzboxuser";
13 | // final String box_password = "badpassword";
14 | final String box_password = "0000";
15 | @SuppressWarnings("unused")
16 | SIDLogin sidLogin = new SIDLogin();
17 | sRetSID = "0000000000000001";
18 |
19 | SIDLogin.check("TestBox", urlstr, box_password, box_user, sRetSID);
20 |
21 | // hier hast du dann die Ergebnisse:
22 | if (SIDLogin.isSidLoginLua())
23 | {
24 | Debug.debug("SID-Login Lua erforderlich: " + SIDLogin.isSidLoginLua());
25 | Debug.debug("SID-Login Lua Username: " + box_user);
26 | Debug.debug("SID: " + SIDLogin.getSessionId());
27 | }
28 | else if (SIDLogin.isSidLogin())
29 | {
30 | Debug.debug("SID-Login erforderlich: " + SIDLogin.isSidLogin());
31 | Debug.debug("SID: " + SIDLogin.getSessionId());
32 | }
33 | else if (SIDLogin.isLogin())
34 | {
35 | Debug.debug("OLD Login, SID nicht erforderlich ");
36 | }
37 | else
38 | {
39 | Debug.debug("Fehler: Login nicht erfolgreich ");
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/CompoundUndoManager.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import javax.swing.SwingUtilities;
4 | import javax.swing.event.DocumentEvent;
5 | import javax.swing.event.DocumentEvent.EventType;
6 | import javax.swing.event.DocumentListener;
7 | import javax.swing.event.UndoableEditEvent;
8 | import javax.swing.event.UndoableEditListener;
9 | import javax.swing.text.AbstractDocument.DefaultDocumentEvent;
10 | import javax.swing.text.JTextComponent;
11 | import javax.swing.undo.CannotUndoException;
12 | import javax.swing.undo.CompoundEdit;
13 | import javax.swing.undo.UndoManager;
14 | import javax.swing.undo.UndoableEdit;
15 |
16 | public class CompoundUndoManager extends UndoManager implements UndoableEditListener, DocumentListener {
17 | class MyCompoundEdit extends CompoundEdit {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | public boolean isInProgress() {
22 | return false;
23 | }
24 |
25 | public void undo() throws CannotUndoException {
26 | if (compoundEdit != null)
27 | compoundEdit.end();
28 | super.undo();
29 | compoundEdit = null;
30 | }
31 | }
32 |
33 | private boolean startCombine = false;
34 |
35 | public CompoundUndoManager(JTextComponent editor) {
36 | this.editor = editor;
37 | editor.getDocument().addUndoableEditListener(this);
38 | }
39 |
40 | public void undo() {
41 | editor.getDocument().addDocumentListener(this);
42 | super.undo();
43 | editor.getDocument().removeDocumentListener(this);
44 | }
45 |
46 | public void redo() {
47 | editor.getDocument().addDocumentListener(this);
48 | super.redo();
49 | editor.getDocument().removeDocumentListener(this);
50 | }
51 |
52 | public void undoableEditHappened(UndoableEditEvent e) {
53 |
54 | if (compoundEdit == null) {
55 | compoundEdit = startCompoundEdit(e.getEdit());
56 | lastLength = editor.getDocument().getLength();
57 | startCombine = false;
58 | return;
59 | }
60 |
61 | if (e.getEdit() instanceof DefaultDocumentEvent) { // Java 9 / 10 05.05.2018
62 |
63 | // Java 6 to 8
64 | DefaultDocumentEvent event = (DefaultDocumentEvent) e.getEdit();
65 |
66 | if (event.getType().equals(EventType.CHANGE)) {
67 | compoundEdit.addEdit(e.getEdit());
68 | return;
69 | }
70 |
71 | int offsetChange = editor.getCaretPosition() - lastOffset;
72 | int lengthChange = editor.getDocument().getLength() - lastLength;
73 |
74 | if (Math.abs(offsetChange) == 1 && Math.abs(lengthChange) == 1) {
75 | compoundEdit.addEdit(e.getEdit());
76 | lastOffset = editor.getCaretPosition();
77 | lastLength = editor.getDocument().getLength();
78 | return;
79 | } else {
80 | compoundEdit.end();
81 | compoundEdit = startCompoundEdit(e.getEdit());
82 | return;
83 | }
84 |
85 | } else { // Java 9 to 10 // 05.05.2018
86 |
87 | if (startCombine && !e.getEdit().isSignificant()) {
88 | compoundEdit.addEdit(e.getEdit());
89 | startCombine = false;
90 | lastOffset = editor.getCaretPosition();
91 | lastLength = editor.getDocument().getLength();
92 | return;
93 | } else {
94 | compoundEdit.end();
95 | compoundEdit = startCompoundEdit(e.getEdit());
96 | return;
97 | }
98 |
99 | }
100 |
101 | }
102 |
103 | private CompoundEdit startCompoundEdit(UndoableEdit anEdit) {
104 | lastOffset = editor.getCaretPosition();
105 | lastLength = editor.getDocument().getLength();
106 | compoundEdit = new MyCompoundEdit();
107 | compoundEdit.addEdit(anEdit);
108 | addEdit(compoundEdit);
109 | return compoundEdit;
110 | }
111 |
112 | public void insertUpdate(final DocumentEvent e) {
113 | SwingUtilities.invokeLater(new Runnable() {
114 |
115 | public void run() {
116 | int offset = e.getOffset() + e.getLength();
117 | offset = Math.min(offset, editor.getDocument().getLength());
118 | editor.setCaretPosition(offset);
119 | }
120 | });
121 | }
122 |
123 | public void removeUpdate(DocumentEvent e) {
124 | editor.setCaretPosition(e.getOffset());
125 | }
126 |
127 | public void pause() {
128 | editor.getDocument().removeUndoableEditListener(this);
129 | }
130 |
131 | public void resume() {
132 | editor.getDocument().addUndoableEditListener(this);
133 | }
134 |
135 | public void changedUpdate(DocumentEvent documentevent) {
136 | }
137 |
138 | public JTextComponent getEditor() {
139 | return this.editor;
140 | }
141 |
142 | /**
143 | * Start to combine the next operations together. Only the next operation is combined.
144 | * The flag is then automatically reset.
145 | */
146 | public void startCombine() {
147 | startCombine = true;
148 | }
149 |
150 | private static final long serialVersionUID = 1L;
151 | public CompoundEdit compoundEdit;
152 | private JTextComponent editor;
153 | private int lastOffset;
154 | private int lastLength;
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/ExampleFileFilter.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | /*
4 | * Copyright (c) 2002 Sun Microsystems, Inc. All Rights Reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * -Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * -Redistribution in binary form must reproduct the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the distribution.
16 | *
17 | * Neither the name of Sun Microsystems, Inc. or the names of contributors
18 | * may be used to endorse or promote products derived from this software
19 | * without specific prior written permission.
20 | *
21 | * This software is provided "AS IS," without a warranty of any kind. ALL
22 | * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
23 | * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
24 | * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT
25 | * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
26 | * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
27 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
28 | * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
29 | * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
30 | * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
31 | * IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 | *
33 | * You acknowledge that Software is not designed, licensed or intended for
34 | * use in the design, construction, operation or maintenance of any nuclear
35 | * facility.
36 | */
37 |
38 | /*
39 | * @(#)ExampleFileFilter.java 1.5 02/06/13
40 | */
41 |
42 | import java.io.File;
43 | import java.util.Hashtable;
44 | import java.util.Enumeration;
45 | import javax.swing.filechooser.*;
46 |
47 | /**
48 | * A convenience implementation of FileFilter that filters out all files except
49 | * for those type extensions that it knows about.
50 | *
51 | * Extensions are of the type ".foo", which is typically found on Windows and
52 | * Unix boxes, but not on Macinthosh. Case is ignored.
53 | *
54 | * Example - create a new filter that filerts out all files but gif and jpg
55 | * image files:
56 | *
57 | * JFileChooser chooser = new JFileChooser(); ExampleFileFilter filter = new
58 | * ExampleFileFilter( new String{"gif", "jpg"}, "JPEG & GIF Images")
59 | * chooser.addChoosableFileFilter(filter); chooser.showOpenDialog(this);
60 | *
61 | * @version 1.5 06/13/02
62 | * @author Jeff Dinkins
63 | */
64 | public class ExampleFileFilter extends FileFilter {
65 |
66 | @SuppressWarnings("unused")
67 | private static String TYPE_UNKNOWN = "Type Unknown";
68 | @SuppressWarnings("unused")
69 | private static String HIDDEN_FILE = "Hidden File";
70 |
71 | private Hashtable filters = null;
72 | private String description = null;
73 | private String fullDescription = null;
74 | private boolean useExtensionsInDescription = true;
75 |
76 | /**
77 | * Creates a file filter. If no filters are added, then all files are
78 | * accepted.
79 | *
80 | * @see #addExtension
81 | */
82 | public ExampleFileFilter() {
83 | this.filters = new Hashtable();
84 | }
85 |
86 | /**
87 | * Creates a file filter that accepts files with the given extension.
88 | * Example: new ExampleFileFilter("jpg");
89 | *
90 | * @see #addExtension
91 | */
92 | public ExampleFileFilter(String extension) {
93 | this(extension, null);
94 | }
95 |
96 | /**
97 | * Creates a file filter that accepts the given file type. Example: new
98 | * ExampleFileFilter("jpg", "JPEG Image Images");
99 | *
100 | * Note that the "." before the extension is not needed. If provided, it
101 | * will be ignored.
102 | *
103 | * @see #addExtension
104 | */
105 | public ExampleFileFilter(String extension, String description) {
106 | this();
107 | if (extension != null)
108 | addExtension(extension);
109 | if (description != null)
110 | setDescription(description);
111 | }
112 |
113 | /**
114 | * Creates a file filter from the given string array. Example: new
115 | * ExampleFileFilter(String {"gif", "jpg"});
116 | *
117 | * Note that the "." before the extension is not needed adn will be ignored.
118 | *
119 | * @see #addExtension
120 | */
121 | public ExampleFileFilter(String[] filters) {
122 | this(filters, null);
123 | }
124 |
125 | /**
126 | * Creates a file filter from the given string array and description.
127 | * Example: new ExampleFileFilter(String {"gif", "jpg"},
128 | * "Gif and JPG Images");
129 | *
130 | * Note that the "." before the extension is not needed and will be ignored.
131 | *
132 | * @see #addExtension
133 | */
134 | public ExampleFileFilter(String[] filters, String description) {
135 | this();
136 | for (int i = 0; i < filters.length; i++) {
137 | // add filters one by one
138 | addExtension(filters[i]);
139 | }
140 | if (description != null)
141 | setDescription(description);
142 | }
143 |
144 | /**
145 | * Return true if this file should be shown in the directory pane, false if
146 | * it shouldn't.
147 | *
148 | * Files that begin with "." are ignored.
149 | *
150 | * @see #getExtension
151 | * @see FileFilter#accepts
152 | */
153 | public boolean accept(File f) {
154 | if (f != null) {
155 | if (f.isDirectory()) {
156 | return true;
157 | }
158 | String extension = getExtension(f);
159 | if (extension != null && filters.get(getExtension(f)) != null) {
160 | return true;
161 | }
162 | ;
163 | }
164 | return false;
165 | }
166 |
167 | /**
168 | * Return the extension portion of the file's name .
169 | *
170 | * @see #getExtension
171 | * @see FileFilter#accept
172 | */
173 | public String getExtension(File f) {
174 | if (f != null) {
175 | String filename = f.getName();
176 | int i = filename.lastIndexOf('.');
177 | if (i > 0 && i < filename.length() - 1) {
178 | return filename.substring(i + 1).toLowerCase();
179 | }
180 | ;
181 | }
182 | return null;
183 | }
184 |
185 | /**
186 | * Adds a filetype "dot" extension to filter against.
187 | *
188 | * For example: the following code will create a filter that filters out all
189 | * files except those that end in ".jpg" and ".tif":
190 | *
191 | * ExampleFileFilter filter = new ExampleFileFilter();
192 | * filter.addExtension("jpg"); filter.addExtension("tif");
193 | *
194 | * Note that the "." before the extension is not needed and will be ignored.
195 | */
196 | public void addExtension(String extension) {
197 | if (filters == null) {
198 | filters = new Hashtable(5);
199 | }
200 | filters.put(extension.toLowerCase(), this);
201 | fullDescription = null;
202 | }
203 |
204 | /**
205 | * Returns the human readable description of this filter. For example:
206 | * "JPEG and GIF Image Files (*.jpg, *.gif)"
207 | *
208 | * @see setDescription
209 | * @see setExtensionListInDescription
210 | * @see isExtensionListInDescription
211 | * @see FileFilter#getDescription
212 | */
213 | public String getDescription() {
214 | if (fullDescription == null) {
215 | if (description == null || isExtensionListInDescription()) {
216 | fullDescription = description == null ? "(" : description + " (";
217 | // build the description from the extension list
218 | Enumeration extensions = filters.keys();
219 | if (extensions != null) {
220 | fullDescription += "." + extensions.nextElement();
221 | while (extensions.hasMoreElements()) {
222 | fullDescription += ", ." + extensions.nextElement();
223 | }
224 | }
225 | fullDescription += ")";
226 | } else {
227 | fullDescription = description;
228 | }
229 | }
230 | return fullDescription;
231 | }
232 |
233 | /**
234 | * Sets the human readable description of this filter. For example:
235 | * filter.setDescription("Gif and JPG Images");
236 | *
237 | * @see setDescription
238 | * @see setExtensionListInDescription
239 | * @see isExtensionListInDescription
240 | */
241 | public void setDescription(String description) {
242 | this.description = description;
243 | fullDescription = null;
244 | }
245 |
246 | /**
247 | * Determines whether the extension list (.jpg, .gif, etc) should show up in
248 | * the human readable description.
249 | *
250 | * Only relevent if a description was provided in the constructor or using
251 | * setDescription();
252 | *
253 | * @see getDescription
254 | * @see setDescription
255 | * @see isExtensionListInDescription
256 | */
257 | public void setExtensionListInDescription(boolean b) {
258 | useExtensionsInDescription = b;
259 | fullDescription = null;
260 | }
261 |
262 | /**
263 | * Returns whether the extension list (.jpg, .gif, etc) should show up in
264 | * the human readable description.
265 | *
266 | * Only relevent if a description was provided in the constructor or using
267 | * setDescription();
268 | *
269 | * @see getDescription
270 | * @see setDescription
271 | * @see setExtensionListInDescription
272 | */
273 | public boolean isExtensionListInDescription() {
274 | return useExtensionsInDescription;
275 | }
276 | }
277 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/FBFWVN.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.util.regex.Matcher;
4 | import java.util.regex.Pattern;
5 |
6 | /**
7 | *
8 | * @author Erwin
9 | */
10 | public class FBFWVN {
11 |
12 | private boolean isOK = false;
13 | private boolean isFritzboxLanguageOK = false;
14 | // private static String sFBFWV10 = "";
15 | private static String sFBFWV81 = "";
16 | private static String sFBFWV82 = "";
17 | private static String sFBFWV83 = "";
18 | private static String sFBFWV90 = "";
19 | private static String sFBFWV100 = "";
20 | private static String sFBFWV110 = "";
21 | private static String sRetFBV = "";
22 | private static String sRetFBFW = "";
23 | private static String sRetFBFWV = "";
24 |
25 | /**
26 | *
27 | * @param sFBFWV_IN
28 | */
29 | public FBFWVN(String sFBFWV_IN) {
30 | // sRetFBFWV = sFBFWV_IN;
31 | FBFWVN0(sFBFWV_IN);
32 | }
33 |
34 | /**
35 | *
36 | * @param sFBFWV_IN
37 | */
38 | public final void FBFWVN0(String sFBFWV_IN)
39 | {
40 |
41 | if (sFBFWV_IN == null) {
42 | sFBFWV_IN = "";
43 | }
44 |
45 | String sFBV = "";
46 | String sFBFW = "";
47 | String sFBFWV = "";
48 |
49 | sFBFWV81 = "0";
50 | sFBFWV82 = "0";
51 | sFBFWV83 = "0";
52 | sFBFWV90 = "";
53 | sFBFWV100 = "";
54 | sFBFWV110 = "";
55 |
56 | isOK = false;
57 | isFritzboxLanguageOK = false;
58 |
59 | // 15.04.2015
60 | int ii = 0;
61 | String ss = "";
62 |
63 | Pattern status1Pattern = Pattern.compile("([^-<]*)-([^-<]*)-([^-<]*)-([^-<]*)-([^-<]*)-([^-<]*)-([^-<]*)-([^-<]*)[|-]?([^-<]*)[|-]?([^-<]*)[|-]?([^-<]*)[|-]?([^-<]*)[|-]?([^-<]*)[|-]?([^-<]*)[|-]?([^<]*)", Pattern.CASE_INSENSITIVE);
64 | Matcher status1Matcher = status1Pattern.matcher(sFBFWV_IN);
65 |
66 | if (status1Matcher.find(0) == true) {
67 |
68 | String[] S10 = new String[status1Matcher.groupCount() + 1];
69 |
70 | if (status1Matcher.groupCount() >= 9) {
71 |
72 | for (int i = 0; i <= status1Matcher.groupCount(); i++) {
73 | // 15.04.2015
74 | ss = status1Matcher.group(i);
75 | S10[i - ii] = ss;
76 | }
77 |
78 | if (S10[8].length() >= 5 && S10[8].length() <= 7) {
79 | sFBFW = S10[1] + " " + S10[8].substring(0, S10[8].length() - 4) + "." + S10[8].substring(S10[8].length() - 4, S10[8].length() - 2) + "." + S10[8].substring(S10[8].length() - 2, S10[8].length());
80 | sFBV = S10[1];
81 | sFBFWV = S10[8].substring(0, S10[8].length() - 4) + "." + S10[8].substring(S10[8].length() - 4, S10[8].length() - 2) + "." + S10[8].substring(S10[8].length() - 2, S10[8].length());
82 |
83 | // sFBFWV10 = S10[1];
84 | sFBFWV81 = S10[8].substring(0, S10[8].length() - 4);
85 | sFBFWV82 = S10[8].substring(S10[8].length() - 4, S10[8].length() - 2);
86 | sFBFWV83 = S10[8].substring(S10[8].length() - 2, S10[8].length());
87 | // sFBFWV90 = S10[9];
88 |
89 | } else if (S10[8].length() == 8) { // 22.06.2018
90 |
91 | sFBFW = S10[1] + " " + S10[8].substring(0, S10[8].length() - 5) + "." + S10[8].substring(S10[8].length() - 5, S10[8].length() - 3) + "." + S10[8].substring(S10[8].length() - 3, S10[8].length());
92 | sFBV = S10[1];
93 | sFBFWV = S10[8].substring(0, S10[8].length() - 5) + "." + S10[8].substring(S10[8].length() - 5, S10[8].length() - 3) + "." + S10[8].substring(S10[8].length() - 3, S10[8].length());
94 |
95 | sFBFWV81 = S10[8].substring(0, S10[8].length() - 5);
96 | sFBFWV82 = S10[8].substring(S10[8].length() - 5, S10[8].length() - 3);
97 | sFBFWV83 = S10[8].substring(S10[8].length() - 3, S10[8].length());
98 |
99 | }
100 |
101 | if (S10[8].length() >= 5) {
102 |
103 | if (status1Matcher.groupCount() >= 9) {
104 | sFBFWV90 = S10[9];
105 | }
106 | if (status1Matcher.groupCount() >= 10) {
107 | sFBFWV100 = S10[10];
108 | }
109 | // 15.08.2015
110 | if (status1Matcher.groupCount() >= 11) {
111 | if (!"".equals(S10[11]) && S10[11].length() > 2) {
112 | S10[11] = S10[11].substring(0, 2);
113 | }
114 | sFBFWV110 = S10[11];
115 | if (!"".equals(S10[11]) && S10[11].length() == 2) {
116 | isFritzboxLanguageOK = true;
117 | }
118 | }
119 |
120 | // 15.04.2015
121 | if (sFBFWV81.length() > 3) {
122 | System.out.println("isOK = false");
123 | } else {
124 | isOK = true;
125 | }
126 |
127 | }
128 | }
129 | }
130 |
131 | sRetFBV = sFBV;
132 | sRetFBFW = sFBFW;
133 | sRetFBFWV = sFBFWV;
134 | }
135 |
136 | /**
137 | *
138 | * @return
139 | */
140 | public final boolean isOK() {
141 | return isOK;
142 | }
143 |
144 | /**
145 | *
146 | * @param sFBFWV_IN
147 | * @return
148 | */
149 | public String getFBFWVN(String sFBFWV_IN) {
150 | // if (sFBFWV_IN == null) sFBFWV_IN = "";
151 | FBFWVN0(sFBFWV_IN);
152 | return sFBFWV81;
153 | }
154 |
155 | /**
156 | *
157 | * @return
158 | */
159 | public String getBoxTypeFBFWVN() {
160 | return sFBFWV81;
161 | }
162 |
163 | /**
164 | *
165 | * @return
166 | */
167 | public String getMajorFBFWVN() {
168 | return sFBFWV82;
169 | }
170 |
171 | /**
172 | *
173 | * @return
174 | */
175 | public String getMinorFBFWVN() {
176 | return sFBFWV83;
177 | }
178 |
179 | /**
180 | *
181 | * @return
182 | */
183 | public String getModFBFWVN() {
184 | return sFBFWV90;
185 | }
186 |
187 | /**
188 | *
189 | * @return
190 | */
191 | public String getFritzbox() {
192 | return sRetFBV;
193 | }
194 |
195 | /**
196 | *
197 | * @return
198 | */
199 | public String getFirmware() {
200 | return sRetFBFWV;
201 | }
202 |
203 | /**
204 | *
205 | * @return
206 | */
207 | public String getFritzboxFirmware() {
208 | return sRetFBFW;
209 | }
210 |
211 | /**
212 | *
213 | * @return
214 | */
215 | public String getFritzboxOEM() {
216 | return sFBFWV100;
217 | }
218 |
219 | /**
220 | *
221 | * @return
222 | */
223 | public String getFritzboxLanguage() {
224 | return sFBFWV110;
225 | }
226 |
227 | /**
228 | *
229 | * @return
230 | */
231 | public final boolean isFritzboxLanguage() {
232 | return isFritzboxLanguageOK;
233 | }
234 |
235 | /**
236 | *
237 | * @return
238 | */
239 | public int getBoxType() { // Muss Integer sein wegen neuen Firmware Typ > 127
240 | // public byte getBoxType() {
241 | // return Byte.parseByte(sFBFWV81);
242 | return Integer.parseInt(sFBFWV81); // Muss Integer sein wegen neuen Firmware Typ > 127
243 | // return sFBFWV81;
244 | // return boxtype;
245 | }
246 |
247 | /**
248 | *
249 | * @return
250 | */
251 | public final byte getMajorFirmwareVersion() {
252 | return Byte.parseByte(sFBFWV82);
253 | // return sFBFWV82;
254 | // return majorFirmwareVersion;
255 | }
256 |
257 | /**
258 | *
259 | * @return
260 | */
261 | public final byte getMinorFirmwareVersion() {
262 | return Byte.parseByte(sFBFWV83);
263 | // return sFBFWV83;
264 | //return minorFirmwareVersion;
265 | }
266 |
267 | /**
268 | *
269 | * @return
270 | */
271 | public final String getModFirmwareVersion() {
272 | //return modFirmwareVersion;
273 | return sFBFWV90;
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/FbQueryLua.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | public class FbQueryLua
4 | {
5 |
6 | private static String sRetv5value = "";
7 |
8 | public FbQueryLua()
9 | {
10 |
11 | }
12 |
13 | private static String sLeft(String sStr, int nPos)
14 | {
15 | String returnString = "";
16 |
17 | if (sStr == null) sStr = "";
18 | //System.out.println(sStr);
19 | if (nPos > sStr.length()) {
20 | nPos = sStr.length();
21 | }
22 |
23 | returnString = sStr.substring(0, nPos);
24 | //System.out.println(sStr);
25 | //System.out.println(returnString);
26 | return returnString;
27 | }
28 |
29 | private static String sRight(String sStr, int nPos)
30 | {
31 | String returnString = "";
32 |
33 | if (sStr == null) sStr = "";
34 |
35 | if (nPos > sStr.length()) {
36 | nPos = sStr.length();
37 | }
38 |
39 | returnString = sStr.substring(sStr.length() - nPos, sStr.length());
40 | //System.out.println(sStr);
41 | return returnString;
42 | }
43 |
44 | private static String sMid(String sStr, int nPos, int nAnz)
45 | {
46 | String returnString = "";
47 | //System.out.println(sStr);
48 | if (sStr == null) sStr = "";
49 |
50 | if ( (nPos > 0) && (nPos <= sStr.length()) )
51 | {
52 | if (nPos > 0) nPos = nPos - 1;
53 | if (nPos >= sStr.length()) {
54 | nPos = sStr.length() - 1;
55 | // nAnz = 1;
56 | }
57 |
58 | // if ((nPos + nAnz) > sStr.length()) nAnz = 0;
59 | if ((nPos + nAnz) > sStr.length()) nAnz = sStr.length() - nPos;
60 |
61 | returnString = sStr.substring(nPos, nPos + nAnz);
62 | }
63 | //System.out.println(sStr);
64 | return returnString;
65 | }
66 |
67 | private static String sRtrimLF(String sStr)
68 | {
69 | String returnString = "";
70 |
71 | if (sStr == null) sStr = "";
72 |
73 | String sTmp = sStr;
74 |
75 | if (sStr.length() > 0) {
76 |
77 | for ( int i = 0; i <= sStr.length(); i++ ) {
78 | if ( sRight(sTmp, 1).equals("\n") )
79 | {
80 | sTmp = sLeft(sTmp, sTmp.length() -1);
81 | // System.out.println(sTmp.length() + " D LF " + i);
82 | } else {
83 | // System.out.println(sTmp.length() + " B LF " + i);
84 | break;
85 | }
86 | // System.out.println(sTmp.length() + " D LF " + i);
87 | }
88 |
89 | returnString = sTmp;
90 | }
91 | //System.out.println(sStr);
92 | return returnString;
93 | }
94 |
95 | /*
96 | public static String sRetIn;
97 | public static String v5string;
98 | public static String v5name;
99 | public static String v5value;
100 | public static int v5index;
101 |
102 |
103 | public FbQueryLua(String sRetIn, String v5string, String v5name, String v5value, int v5index)
104 | {
105 | this.sRetIn = sRetIn;
106 | this.v5string = v5string;
107 | this.v5name = v5name;
108 | this.v5value = v5value;
109 | this.v5index = v5index;
110 | }
111 | */
112 |
113 | //@SuppressWarnings({"SuspiciousIndentAfterControlStatement", "ConvertToStringSwitch"})
114 | public static int sQueryLuaAll(String sRetIn, String v5string, String v5name, String v5value, int v5index)
115 | {
116 | String sStrIn = ""; String sTmpFirst = ""; String sTmpLast = "";
117 | String sTmp1 = ""; String sTmp2 = ""; String sTmp3 = ""; String sTmp4 = "";
118 |
119 | int nTmp = 0; int nTmp1 = 0; int nTmp2 = 0;
120 | int nTmp4 = 0;
121 | int nRet = 0; int nDQ = 0; int nLF = 0; int nAMP = 0; int nKomma = 0;
122 | int nDP; int nSP; // 04.07.2018
123 |
124 | String sQueryStringIn = ""; String sQueryName = ""; String sQueryRetValue = ""; String sQueryNameIn = "";
125 | String[] sQueryNameArray = new String[10];
126 |
127 | int nQueryIndex = 0;
128 | int nIsSID = 0;
129 |
130 | v5value = "";
131 | sStrIn = sRetIn;
132 | // v5string = " Test ";
133 | sQueryStringIn = v5string.trim();
134 | // System.out.println(sQueryStringIn + " sQueryStringIn");
135 | sQueryName = v5name.trim(); sQueryNameIn = v5name.trim();
136 | nQueryIndex = v5index;
137 |
138 | if ( sLeft(sQueryStringIn, 1).equals("?") )
139 | {
140 | sQueryStringIn = sRight(sQueryStringIn, sQueryStringIn.length() -1);
141 | // System.out.println(sQueryStringIn);
142 | }
143 |
144 | // System.out.println(sLeft(sQueryStringIn, 1));
145 | // System.out.println(FbQueryLua.sLeft(sQueryStringIn, 1));
146 | // sTmp1 = sLeft(sQueryStringIn, 1);
147 | // System.out.println(sTmp1);
148 |
149 | if ( sLeft(sQueryStringIn, 1).equals("&") )
150 | {
151 | // System.out.println(FbQueryLua.sLeft(sQueryStringIn, 1));
152 | sQueryStringIn = sRight(sQueryStringIn, sQueryStringIn.length() -1);
153 | // System.out.println(sQueryStringIn);
154 | }
155 |
156 | sStrIn = sRtrimLF(sStrIn);
157 | // System.out.println(sStrIn.length() + " sStrIn");
158 | // System.out.println("sStrIn: " + sStrIn);
159 |
160 | if ( (sLeft(sStrIn, 1).equals("{")) && (sRight(sStrIn, 1).equals("}")) ) { // 04.07.2018
161 | if ( (sLeft(sStrIn, 2).equals("{\n") ) && (sRight(sStrIn, 1).equals("}") ) ) {
162 | sStrIn = sLeft(sStrIn, sStrIn.length() -1); sStrIn = sRight(sStrIn, sStrIn.length() -2);
163 | } else if ( (sLeft(sStrIn, 1).equals("{")) && (sRight(sStrIn, 1).equals("}")) ) { // 04.07.2018
164 | sStrIn = sLeft(sStrIn, sStrIn.length() -1); sStrIn = sRight(sStrIn, sStrIn.length() -1); // 04.07.2018
165 | }
166 |
167 | // System.out.println(sStrIn);
168 | // System.out.println(sStrIn.length());
169 |
170 | for ( int i = 1; i <= sStrIn.length(); i++ ) {
171 | if ( sMid(sStrIn, i, 1).equals("\n") ) nLF = nLF + 1;
172 | // System.out.println(i + ": " + nLF);
173 | }
174 | if ( nLF >= 0 ) nLF = nLF + 1;
175 | // System.out.println(nLF);
176 |
177 | for ( int i = 1; i <= sQueryStringIn.length(); i++ ) {
178 | if ( sMid(sQueryStringIn, i, 1).equals("&") ) nAMP = nAMP + 1;
179 | // System.out.println(i + ": " + nAMP);
180 | }
181 | if ( nAMP >= 0 ) nAMP = nAMP + 1;
182 | // System.out.println(nAMP);
183 |
184 | if ( nLF >= nAMP )
185 | {
186 | sQueryNameArray = new String[nLF + 1];
187 | } else {
188 | sQueryNameArray = new String[nAMP + 1];
189 | }
190 |
191 | // System.out.println(sQueryNameArray.length);
192 | // char chr0 = 0;
193 | // sQueryNameArray[sQueryNameArray.length -1] = chr0;
194 | // sQueryNameArray[sQueryNameArray.length -1] = "";
195 |
196 | for ( nTmp = 1; nTmp <= nAMP; nTmp++ ) {
197 |
198 | sTmp1 = "";
199 |
200 | for ( nTmp2 = 1; nTmp2 <= sQueryStringIn.length(); nTmp2++ ) {
201 | if ( sMid(sQueryStringIn, nTmp2, 1).equals("&") )
202 | {
203 | sQueryStringIn = sRight(sQueryStringIn, sQueryStringIn.length() - nTmp2);
204 | break;
205 | } else {
206 | sTmp1 = sTmp1 + sMid(sQueryStringIn, nTmp2, 1);
207 | }
208 | }
209 |
210 | sTmp3 = sTmp1; sTmp4 = "";
211 |
212 | for ( nTmp4 = 1; nTmp4 <= sTmp3.length(); nTmp4++ ) {
213 | if ( sMid(sTmp3, nTmp4, 1).equals("=") )
214 | {
215 | sTmp3 = sRight(sTmp3, sTmp3.length() - nTmp4);
216 | break;
217 | } else {
218 | sTmp4 = sTmp4 + sMid(sTmp3, nTmp4, 1);
219 | }
220 | }
221 |
222 | if ( nIsSID == 1 )
223 | {
224 | sQueryNameArray[nTmp -1] = sTmp4.trim();
225 | } else {
226 | if ( nIsSID == 0 )
227 | {
228 | if ( sTmp4.toLowerCase().trim().equals("sid") )
229 | {
230 | nIsSID = 1;
231 | } else {
232 | sQueryNameArray[nTmp] = sTmp4.trim();
233 | }
234 | }
235 | }
236 |
237 | // System.out.println(sQueryStringIn);
238 | // System.out.println(nTmp2);
239 | // System.out.println(nTmp);
240 | // System.out.println(sTmp1 + "\n" + sTmp1.length());
241 | // System.out.println(sTmp4 + "\n" + sTmp4.length());
242 | // System.out.println(sTmp3 + "\n" + sTmp3.length());
243 |
244 | }
245 |
246 | if ( nIsSID == 1 ) nAMP = nAMP - 1;
247 |
248 | if ( nLF >= nAMP )
249 | {
250 |
251 | for ( nTmp = 1; nTmp <= nLF; nTmp++ )
252 | {
253 |
254 | sTmp1 = "";
255 |
256 | if ( nAMP <= nLF )
257 | {
258 | sQueryName = sQueryNameArray[nTmp];
259 | if ( "".equals(sQueryName) || sQueryName == null )
260 | {
261 | char chr = 0;
262 | // sQueryName = chr;
263 | sQueryName = String.valueOf(chr);
264 | // sQueryName = "0000";
265 | // sQueryName = "\0";
266 | }
267 | } else {
268 | char chr = 0;
269 | // sQueryName = chr;
270 | sQueryName = String.valueOf(chr);
271 | // sQueryName = "0001";
272 | // sQueryName = "\0";
273 | }
274 | // char chr = 0;
275 | // System.out.println(sQueryName + "---" + "\u0000" + "--" + "");
276 | if ( sQueryName.length() >= 1 )
277 | // System.out.println("---: " + (int) sQueryName.charAt(0));
278 |
279 | for ( nTmp2 = 1; nTmp2 <= sStrIn.length(); nTmp2++ )
280 | {
281 | if ( sMid(sStrIn, nTmp2, 1).equals("\n") )
282 | {
283 | sStrIn = sRight(sStrIn, sStrIn.length() - nTmp2);
284 | break;
285 | } else {
286 | sTmp1 = sTmp1 + sMid(sStrIn, nTmp2, 1);
287 | }
288 | }
289 |
290 | // if ( sTmp1.trim() == "" ) System.out.println( "--> " + sTmp1 + "" + "\r\n" + nTmp);
291 |
292 | sTmp2 = "";
293 | nDQ = 0;
294 | sTmpFirst = "";
295 | sTmpLast = "";
296 | nDP = 0; nSP = 0; // 04.07.2018
297 |
298 | for ( nTmp1 = 1; nTmp1 <= sTmp1.length(); nTmp1++ )
299 | {
300 |
301 | if ( sMid(sTmp1, nTmp1, 1).equals("\"") )
302 | {
303 | nDQ = nDQ + 1; nDP = 0; // 04.07.2018
304 | } else if ( sMid(sTmp1, nTmp1, 1).equals(":") ) {
305 | nDP = 1; // 04.07.2018
306 | if ( nDQ == 1 )
307 | {
308 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
309 | } else {
310 | sTmpFirst = sTmp2;
311 | sTmp2 = "";
312 | if ( nDQ == 2 )
313 | {
314 | nDQ = 0;
315 | }
316 | }
317 |
318 | } else if ( sMid(sTmp1, nTmp1, 1).equals(",") ) {
319 |
320 | if ( nDQ == 2 || nDP == 2 ) { // 04.07.2018
321 | nKomma = 1; nDP = 0; nSP = 0; sTmp2 = "";
322 | }
323 |
324 | } else {
325 |
326 | if ( nDQ == 2 ) nDQ = 0; // 04.07.2018
327 |
328 | if ( nDP == 2 || nDQ == 1 ) { // 04.07.2018
329 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
330 | } else if ( (nDP == 1) && (nDQ == 0) ) {
331 | if ( (nDP == 1) && (nSP == 0) && (sMid(sTmp1, nTmp1, 1).equals(" ")) ) {
332 | nSP = 1; nDP = 2;
333 | } else if ( (nDP == 1) && (nSP == 0) && (!sMid(sTmp1, nTmp1, 1).equals(" ")) ) {
334 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
335 | nSP = 0; nDP = 2;
336 | }
337 | }
338 | }
339 |
340 | }
341 |
342 | sTmpLast = sTmp2;
343 |
344 | // System.out.println(sTmpFirst);
345 | // System.out.println(sTmpLast);
346 | // System.out.println(sQueryName);
347 |
348 | if ( sTmpFirst.toLowerCase().equals(sQueryName.toLowerCase()) )
349 | {
350 | v5value = sTmpLast.trim(); nRet = 1;
351 | sQueryRetValue = sQueryRetValue + sTmpLast.trim() + "\n";
352 | } else {
353 | sQueryRetValue = sQueryRetValue + "\n";
354 | }
355 |
356 | if ( nKomma == 1 ) nKomma = 0;
357 | // System.out.println(sQueryRetValue);
358 | if ( (sQueryNameIn.toLowerCase().equals(sQueryName.toLowerCase()) ) && (nQueryIndex == nTmp) )
359 | {
360 | sQueryRetValue = sTmpLast.trim() + "\n\n";
361 | break;
362 | }
363 |
364 | }
365 | }
366 |
367 | if ( nRet == 1 ) v5value = sQueryRetValue; else v5value = "";
368 | // System.out.println(sQueryRetValue);
369 | }
370 |
371 | if ( nRet == 1 ) sRetv5value = sQueryRetValue; else sRetv5value = "";
372 | // System.out.println(sQueryRetValue);
373 | return nRet;
374 | // return new FbQueryLua(sRetIn, v5string, v5name, v5value, v5index);
375 | // return new sQueryLuaAll(sRetIn, v5string, v5name, v5value, v5index);
376 | // return this;
377 | }
378 |
379 | public static int sQueryLua(String sRetIn, String v5name, String v5value)
380 | {
381 | // 13.07.2013 // 04.07.2018
382 | String sStrIn; String sTmpFirst; String sTmpLast;
383 | String sTmp1; String sTmp2;
384 | int nRet;
385 | int nTmp; int nTmp1; int nTmp2;
386 | int nKomma; int nDQ; int nLF;
387 |
388 | int nDP; int nSP; // 04.07.2018
389 |
390 | sStrIn = sRetIn; nRet = 0; nLF = 0; v5value = ""; nKomma = 0;
391 |
392 | sStrIn = sRtrimLF(sStrIn);
393 |
394 | if ( (sLeft(sStrIn, 1).equals("{")) && (sRight(sStrIn, 1).equals("}")) ) { // 04.07.2018
395 | if ( (sLeft(sStrIn, 2).equals("{\n") ) && (sRight(sStrIn, 1).equals("}") ) ) {
396 | sStrIn = sLeft(sStrIn, sStrIn.length() -1); sStrIn = sRight(sStrIn, sStrIn.length() -2);
397 | } else if ( (sLeft(sStrIn, 1).equals("{")) && (sRight(sStrIn, 1).equals("}")) ) { // 04.07.2018
398 | sStrIn = sLeft(sStrIn, sStrIn.length() -1); sStrIn = sRight(sStrIn, sStrIn.length() -1); // 04.07.2018
399 | }
400 |
401 | for ( int i = 1; i <= sStrIn.length(); i++ ) {
402 | if ( sMid(sStrIn, i, 1).equals("\n") ) nLF = nLF + 1;
403 | // System.out.println(i + ": " + nLF);
404 | }
405 | if ( nLF >= 0 ) nLF = nLF + 1;
406 | // System.out.println(nLF);
407 |
408 | for ( nTmp = 1; nTmp <= nLF; nTmp++ ) {
409 |
410 | sTmp1 = "";
411 |
412 | for ( nTmp2 = 1; nTmp2 <= sStrIn.length(); nTmp2++ )
413 | {
414 | if ( sMid(sStrIn, nTmp2, 1).equals("\n") )
415 | {
416 | sStrIn = sRight(sStrIn, sStrIn.length() - nTmp2);
417 | break;
418 | } else {
419 | sTmp1 = sTmp1 + sMid(sStrIn, nTmp2, 1);
420 | }
421 | }
422 |
423 | sTmp2 = ""; nDQ = 0; sTmpFirst = ""; sTmpLast = "";
424 | nDP = 0; nSP = 0; // 04.07.2018
425 |
426 | for ( nTmp1 = 1; nTmp1 <= sTmp1.length(); nTmp1++ )
427 | {
428 | switch (sMid(sTmp1, nTmp1, 1)) {
429 | case "\"" : nDQ = nDQ + 1; nDP = 0; break; // 04.07.2018
430 | case ":":
431 | nDP = 1; // 04.07.2018
432 | if ( nDQ == 1 ) {
433 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
434 | } else {
435 | sTmpFirst = sTmp2;
436 | sTmp2 = "";
437 | if ( nDQ == 2 ) nDQ = 0;
438 | }
439 | break;
440 | case ",":
441 | if ( nDQ == 2 || nDP == 2 ) { // 04.07.2018
442 | nKomma = 1; nDP = 0; nSP = 0; sTmp2 = "";
443 | }
444 | break;
445 | default:
446 | if ( nDQ == 2 ) nDQ = 0; // 04.07.2018
447 |
448 | if ( nDP == 2 || nDQ == 1 ) { // 04.07.2018
449 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
450 | } else if ( (nDP == 1) && (nDQ == 0) ) {
451 | if ( (nDP == 1) && (nSP == 0) && (sMid(sTmp1, nTmp1, 1).equals(" ")) ) {
452 | nSP = 1; nDP = 2;
453 | } else if ( (nDP == 1) && (nSP == 0) && (!sMid(sTmp1, nTmp1, 1).equals(" ")) ) {
454 | sTmp2 = sTmp2 + sMid(sTmp1, nTmp1, 1);
455 | nSP = 0; nDP = 2;
456 | }
457 | }
458 | break;
459 | }
460 | }
461 |
462 | sTmpLast = sTmp2;
463 |
464 | // 26.05.2011
465 | if ( sTmpFirst.toLowerCase().equals(v5name.toLowerCase()) ) {
466 | v5value = sTmpLast.trim(); nRet = 1;
467 | }
468 |
469 | if ( nKomma == 1 ) nKomma = 0;
470 |
471 | }
472 |
473 | }
474 |
475 | if ( nRet == 1 ) sRetv5value = v5value; else sRetv5value = "";
476 | return nRet;
477 |
478 | }
479 |
480 | public static String sQueryLuaAllsRetValue()
481 | {
482 | return sRetv5value;
483 | }
484 |
485 | public static String Value()
486 | {
487 | return sRetv5value;
488 | }
489 |
490 | }
491 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/HttpPost.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.io.OutputStreamWriter;
7 | import java.net.HttpURLConnection;
8 | import java.net.URL;
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 |
12 | public class HttpPost {
13 |
14 | private static boolean isok;
15 |
16 | public HttpPost() {
17 | isok = false;
18 | }
19 |
20 | public String Post(String urlstr, String postdata) {
21 | String sRet = "";
22 | try {
23 |
24 | if (urlstr == null) {
25 | urlstr = "";
26 | }
27 | if (postdata == null) {
28 | postdata = "";
29 | }
30 |
31 | String encoding = "ISO-8859-1";
32 |
33 | URL url = new URL(urlstr);
34 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
35 |
36 | connection.setConnectTimeout(5000);
37 | connection.setReadTimeout(15000);
38 |
39 | connection.setDoInput(true);
40 | connection.setDoOutput(true);
41 | connection.setUseCaches(false);
42 |
43 | if (!"".equals(postdata)) {
44 | connection.setRequestMethod("POST");
45 | connection.setRequestProperty("Content-Type",
46 | "application/x-www-form-urlencoded");
47 | connection.setRequestProperty("Content-Length", String.valueOf(postdata.length()));
48 |
49 | OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
50 | writer.write(postdata);
51 | writer.flush();
52 | writer.close();
53 |
54 | // System.out.println( "POST" );
55 | } else {
56 | connection.setRequestMethod("GET");
57 | connection.setRequestProperty("Content-Type",
58 | "application/x-www-form-urlencoded");
59 | // System.out.println( "GET" );
60 | }
61 |
62 | String contentType = connection.getContentType();
63 | int encodingStart = contentType.indexOf("charset=");
64 | if (encodingStart != -1) {
65 | encoding = contentType.substring(encodingStart + 8);
66 | }
67 |
68 | encoding = encoding.replace(";", ""); // ; wird zurück gegeben und verursacht einen Fehler
69 | encoding = encoding.replace("\"", ""); // " wird zurück gegeben und verursacht einen Fehler 08.08.2015
70 |
71 | // System.out.println( encoding );
72 |
73 | if (connection.getResponseCode() == 200) {
74 |
75 | BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));
76 |
77 | // for ( String line; (line = reader.readLine()) != null; )
78 | // {
79 | //// System.out.println( line );
80 | //// sRet += line + '\n';
81 | // sRet += line;
82 | // }
83 |
84 | int c;
85 | while ((c = reader.read()) != -1) {
86 | // System.out.print((char) c);
87 | sRet += (char) c;
88 | }
89 |
90 | reader.close();
91 |
92 | isok = true;
93 |
94 | }
95 |
96 | connection.disconnect();
97 | //System.out.println( connection.getResponseCode() );
98 | //System.out.println( connection.getResponseMessage() );
99 | } catch (IOException ex) {
100 | Logger.getLogger(HttpPost.class.getName()).log(Level.SEVERE, null, ex);
101 | }
102 | return sRet;
103 | }
104 |
105 | public String Post2(String urlstr, String postdata) {
106 | String sRet = "";
107 | try {
108 |
109 | if (urlstr == null) {
110 | urlstr = "";
111 | }
112 | if (postdata == null) {
113 | postdata = "";
114 | }
115 |
116 | String encoding = "ISO-8859-1";
117 |
118 | URL url = new URL(urlstr);
119 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
120 |
121 | connection.setConnectTimeout(5000);
122 | connection.setReadTimeout(15000);
123 |
124 | connection.setDoInput(true);
125 | connection.setDoOutput(true);
126 | connection.setUseCaches(false);
127 |
128 | if (!"".equals(postdata)) {
129 | connection.setRequestMethod("POST");
130 | connection.setRequestProperty("Content-Type",
131 | "application/x-www-form-urlencoded");
132 | connection.setRequestProperty("Content-Length", String.valueOf(postdata.length()));
133 |
134 | OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
135 | writer.write(postdata);
136 | writer.flush();
137 | writer.close();
138 |
139 | // System.out.println( "POST" );
140 | } else {
141 | connection.setRequestMethod("GET");
142 | connection.setRequestProperty("Content-Type",
143 | "application/x-www-form-urlencoded");
144 | // System.out.println( "GET" );
145 | }
146 |
147 | String contentType = connection.getContentType();
148 | int encodingStart = contentType.indexOf("charset=");
149 | if (encodingStart != -1) {
150 | encoding = contentType.substring(encodingStart + 8);
151 | }
152 |
153 | encoding = encoding.replace(";", ""); // ; wird zurück gegeben und verursacht einen Fehler
154 | encoding = encoding.replace("\"", ""); // " wird zurück gegeben und verursacht einen Fehler 08.08.2015
155 |
156 | // System.out.println( encoding );
157 |
158 | if (connection.getResponseCode() == 200) {
159 |
160 | BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));
161 |
162 | for (String line; (line = reader.readLine()) != null;) {
163 | //// System.out.println( line );
164 | //// sRet += line + '\n';
165 | sRet += line;
166 | }
167 |
168 | // int c;
169 | // while ((c = reader.read()) != -1) {
170 | //// System.out.print((char) c);
171 | // sRet += (char) c;
172 | // }
173 |
174 | reader.close();
175 |
176 | isok = true;
177 |
178 | }
179 |
180 | connection.disconnect();
181 | //System.out.println( connection.getResponseCode() );
182 | //System.out.println( connection.getResponseMessage() );
183 |
184 | } catch (IOException ex) {
185 | Logger.getLogger(HttpPost.class.getName()).log(Level.SEVERE, null, ex);
186 | }
187 | return sRet;
188 | }
189 |
190 | public boolean isOK() {
191 | return isok;
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/JTextPane2.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.awt.Color;
4 | import java.awt.Dimension;
5 | import java.awt.event.KeyEvent;
6 | import java.awt.event.KeyListener;
7 |
8 | import javax.swing.JTextPane;
9 | import javax.swing.text.BadLocationException;
10 | import javax.swing.text.Document;
11 | import javax.swing.text.Highlighter;
12 | import javax.swing.text.JTextComponent;
13 | import javax.swing.text.StyledDocument;
14 |
15 | public class JTextPane2 extends JTextPane implements KeyListener {
16 |
17 | private static final long serialVersionUID = 1L;
18 |
19 | public JTextPane2() {
20 | wrap = false;
21 | myLineTerm = "\n";
22 | origLineTerm = "\n";
23 | maxCharacters = 0;
24 | insertMode = true;
25 | }
26 |
27 | public JTextPane2(boolean wrap) {
28 | this.wrap = false;
29 | myLineTerm = "\n";
30 | origLineTerm = "\n";
31 | maxCharacters = 0;
32 | insertMode = true;
33 | this.wrap = wrap;
34 | }
35 |
36 | public JTextPane2(StyledDocument doc) {
37 | super(doc);
38 | wrap = false;
39 | myLineTerm = "\n";
40 | origLineTerm = "\n";
41 | maxCharacters = 0;
42 | insertMode = true;
43 | }
44 |
45 | public boolean getScrollableTracksViewportWidth() {
46 | if (wrap)
47 | return super.getScrollableTracksViewportWidth();
48 | else
49 | return false;
50 | }
51 |
52 | public void setSize(Dimension d) {
53 | if (!wrap && d.width < getParent().getSize().width)
54 | d.width = getParent().getSize().width;
55 | super.setSize(d);
56 | }
57 |
58 | void setLineWrap(boolean wrap) {
59 | setVisible(false);
60 | this.wrap = wrap;
61 | setVisible(true);
62 | }
63 |
64 | String getLineTermName() {
65 | if ("\r".equals(myLineTerm))
66 | return "Mac";
67 | if ("\n".equals(myLineTerm))
68 | return "UNIX";
69 | if ("\r\n".equals(myLineTerm))
70 | return "DOS";
71 | else
72 | return "UNIX";
73 | }
74 |
75 | void setLineTerm(int lineTermConst) {
76 | switch (lineTermConst) {
77 | case 2: // '\002'
78 | myLineTerm = "\n";
79 | break;
80 |
81 | case 1: // '\001'
82 | myLineTerm = "\r";
83 | break;
84 |
85 | case 0: // '\0'
86 | myLineTerm = "\r\n";
87 | break;
88 | }
89 | }
90 |
91 | public void setLineTerm(String newLineTerm) {
92 | myLineTerm = newLineTerm;
93 | }
94 |
95 | public String getLineTerm() {
96 | return myLineTerm;
97 | }
98 |
99 | public void keyTyped(KeyEvent keyevent) {
100 | }
101 |
102 | public void keyPressed(KeyEvent keyevent) {
103 | }
104 |
105 | public void keyReleased(KeyEvent arg0) {
106 | if (arg0.getKeyCode() == 155)
107 | toggleInsertMode();
108 | }
109 |
110 | public boolean isInsertMode() {
111 | return insertMode;
112 | }
113 |
114 | public void toggleInsertMode() {
115 | insertMode = !insertMode;
116 | }
117 |
118 | public void setInsertMode(boolean insertMode) {
119 | this.insertMode = insertMode;
120 | }
121 |
122 | public static void findText(JTextPane2 pane, String s) {
123 | highlight(pane, s, 0);
124 | }
125 |
126 | public static void findAll(JTextPane2 pane, String s) {
127 | highlight(pane, s, 1);
128 | }
129 |
130 | public static void replaceText(JTextPane2 pane, String s) {
131 | replace(pane, s, 0);
132 | }
133 |
134 | public static void replaceAll(JTextPane2 pane, String s) {
135 | replace(pane, s, 1);
136 | }
137 |
138 | public static void highlight(JTextComponent textComp, String pattern, int findAll) {
139 | MyHighlightPainter myHighlightPainter = new MyHighlightPainter(Color.yellow);
140 |
141 | removeHighlights(textComp);
142 | if (pattern.length() > 0)
143 | try {
144 | Highlighter hilite = textComp.getHighlighter();
145 | Document doc = textComp.getDocument();
146 | String text = doc.getText(0, doc.getLength());
147 | text = text.toUpperCase();
148 | pattern = pattern.toUpperCase();
149 | int pos = textComp.getCaretPosition();
150 | if ((pos = text.indexOf(pattern, pos)) != -1)
151 | if (findAll == 0) {
152 | hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);
153 | textComp.setCaretPosition(pos + pattern.length());
154 | textComp.setSelectionStart(pos);
155 | textComp.setSelectionEnd(pos + pattern.length());
156 | } else {
157 | for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += pattern.length())
158 | hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);
159 |
160 | }
161 | } catch (BadLocationException badlocationexception) {
162 | }
163 | }
164 |
165 | private static void replace(JTextComponent textComp, String pattern, int replaceAll) {
166 | removeHighlights(textComp);
167 | Document doc = textComp.getDocument();
168 | String text = "";
169 | try {
170 | text = doc.getText(0, doc.getLength());
171 | int pos = textComp.getCaretPosition();
172 | if (textComp.getSelectedText() != null) {
173 | String replacement = pattern;
174 | pattern = textComp.getSelectedText();
175 | if (replaceAll == 0) {
176 | textComp.replaceSelection(replacement);
177 | } else {
178 | textComp.replaceSelection(replacement);
179 | text = doc.getText(0, doc.getLength());
180 | for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += replacement.length()) {
181 | textComp.setSelectionStart(pos);
182 | textComp.setSelectionEnd(pos + pattern.length());
183 | textComp.replaceSelection(replacement);
184 | }
185 |
186 | }
187 | }
188 | } catch (BadLocationException e1) {
189 | e1.printStackTrace();
190 | }
191 | }
192 |
193 | private static void removeHighlights(JTextComponent textComp) {
194 | @SuppressWarnings("unused")
195 | MyHighlightPainter myHighlightPainter = new MyHighlightPainter(Color.yellow);
196 | Highlighter hilite = textComp.getHighlighter();
197 | javax.swing.text.Highlighter.Highlight hilites[] = hilite.getHighlights();
198 | for (int i = 0; i < hilites.length; i++)
199 | if (hilites[i].getPainter() instanceof MyHighlightPainter)
200 | hilite.removeHighlight(hilites[i]);
201 | }
202 |
203 | boolean wrap;
204 | public static final int DOS_LINE_END = 0;
205 | public static final int MACOS_LINE_END = 1;
206 | public static final int UNIX_LINE_END = 2;
207 | private String myLineTerm;
208 | @SuppressWarnings("unused")
209 | private String origLineTerm;
210 | int maxCharacters;
211 | private boolean insertMode;
212 | }
213 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/MyHighlightPainter.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.awt.Color;
4 |
5 | public class MyHighlightPainter extends javax.swing.text.DefaultHighlighter.DefaultHighlightPainter {
6 |
7 | public MyHighlightPainter(Color color) {
8 | super(color);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/MyProperties.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.OutputStream;
6 | import java.io.StringReader;
7 | import java.util.Iterator;
8 | import java.util.Properties;
9 | import java.util.Set;
10 |
11 | import javax.xml.parsers.DocumentBuilder;
12 | import javax.xml.parsers.DocumentBuilderFactory;
13 | import javax.xml.parsers.ParserConfigurationException;
14 | import javax.xml.transform.Transformer;
15 | import javax.xml.transform.TransformerConfigurationException;
16 | import javax.xml.transform.TransformerException;
17 | import javax.xml.transform.TransformerFactory;
18 | import javax.xml.transform.dom.DOMSource;
19 | import javax.xml.transform.stream.StreamResult;
20 |
21 | import org.w3c.dom.Document;
22 | import org.w3c.dom.Element;
23 | import org.w3c.dom.Node;
24 | import org.w3c.dom.NodeList;
25 | import org.xml.sax.EntityResolver;
26 | import org.xml.sax.ErrorHandler;
27 | import org.xml.sax.InputSource;
28 | import org.xml.sax.SAXException;
29 | import org.xml.sax.SAXParseException;
30 |
31 | public class MyProperties extends Properties {
32 |
33 | private static final long serialVersionUID = 1L;
34 | @SuppressWarnings("unused")
35 | private static final String PROPS_DTD_URI = "http://java.sun.com/dtd/properties.dtd";
36 | @SuppressWarnings("unused")
37 | private static final String PROPS_DTD = "";
38 | @SuppressWarnings("unused")
39 | private static final String EXTERNAL_XML_VERSION = "1.0";
40 |
41 | public MyProperties() {
42 | }
43 |
44 | public synchronized void loadFromXML(InputStream in) throws IOException {
45 | if (in == null)
46 | throw new NullPointerException();
47 | try {
48 | load(this, in);
49 | } catch (Exception e) {
50 | throw new IOException("Konnte Einstellungen nicht laden!");
51 | }
52 | }
53 |
54 | public synchronized void storeToXML(OutputStream os, String comment)
55 | throws IOException {
56 | if (os == null) {
57 | throw new NullPointerException();
58 | } else {
59 | save(this, os, comment, "UTF-8");
60 | return;
61 | }
62 | }
63 |
64 | public synchronized Object setProperty(String key, String value) {
65 | return super.setProperty(key, value);
66 | }
67 |
68 | public String getProperty(String key) {
69 | // Fehler: NullPointerException wenn der key Fehlt korrigiert 22.02.2014
70 | if (super.getProperty(key) == null) {
71 | super.setProperty(key, "");
72 | System.out.println("import getProperties NullPointerException: "
73 | + key);
74 | }
75 | return super.getProperty(key);
76 | }
77 |
78 | public String getProperty(String key, String defaultValue) {
79 | // Fehler: defaultValue wurde nicht gesetzt bei Leerstring korrigiert
80 | // 22.02.2014
81 | String val = super.getProperty(key, defaultValue);
82 |
83 | if (val.trim().equals("")) {
84 | System.out.println("importPropertiesDefaultValue: " + defaultValue);
85 | super.setProperty(key, defaultValue);
86 | }
87 | return super.getProperty(key, defaultValue);
88 | }
89 |
90 | public Object remove(Object key) {
91 | return super.remove(key);
92 | }
93 |
94 | public static void load(Properties props, InputStream in)
95 | throws IOException, SAXException {
96 | Document doc = null;
97 | doc = getLoadingDoc(in);
98 | Element propertiesElement = (Element) doc.getChildNodes().item(1);
99 | String xmlVersion = propertiesElement.getAttribute("version");
100 | if (xmlVersion.compareTo("1.0") > 0) {
101 | throw new SAXException(
102 | (new StringBuilder(
103 | "Exported Properties file format version "))
104 | .append(xmlVersion)
105 | .append(" is not supported. This java installation can read")
106 | .append(" versions ")
107 | .append("1.0")
108 | .append(" or older. You")
109 | .append(" may need to install a newer version of JDK.")
110 | .toString());
111 | } else {
112 | importProperties(props, propertiesElement);
113 | return;
114 | }
115 | }
116 |
117 | public static Document getLoadingDoc(InputStream in) throws SAXException,
118 | IOException {
119 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
120 | dbf.setIgnoringElementContentWhitespace(true);
121 | dbf.setValidating(true);
122 | dbf.setCoalescing(true);
123 | dbf.setIgnoringComments(true);
124 | try {
125 | DocumentBuilder db = dbf.newDocumentBuilder();
126 | db.setEntityResolver(new EntityResolver() {
127 |
128 | public InputSource resolveEntity(String pid, String sid)
129 | throws SAXException {
130 | if (sid.equals("http://java.sun.com/dtd/properties.dtd")) {
131 | InputSource is = new InputSource(
132 | new StringReader(
133 | ""));
134 | is.setSystemId("http://java.sun.com/dtd/properties.dtd");
135 | return is;
136 | } else {
137 | throw new SAXException((new StringBuilder(
138 | "Invalid system identifier: ")).append(sid)
139 | .toString());
140 | }
141 | }
142 |
143 | });
144 | db.setErrorHandler(new ErrorHandler() {
145 |
146 | public void error(SAXParseException x) throws SAXException {
147 | throw x;
148 | }
149 |
150 | public void fatalError(SAXParseException x) throws SAXException {
151 | throw x;
152 | }
153 |
154 | public void warning(SAXParseException x) throws SAXException {
155 | throw x;
156 | }
157 |
158 | });
159 | InputSource is = new InputSource(in);
160 | return db.parse(is);
161 | } catch (ParserConfigurationException x) {
162 | throw new Error(x);
163 | }
164 | }
165 |
166 | public static void importProperties(Properties props,
167 | Element propertiesElement) {
168 | NodeList entries = propertiesElement.getChildNodes();
169 | int numEntries = entries.getLength();
170 | int start = numEntries > 0
171 | && entries.item(0).getNodeName().equals("comment") ? 1 : 0;
172 | for (int i = start; i < numEntries; i++) {
173 | Element entry = (Element) entries.item(i);
174 | if (entry.hasAttribute("key")) {
175 | Node n = entry.getFirstChild();
176 | String val = n == null ? "" : n.getNodeValue();
177 | props.setProperty(entry.getAttribute("key"), val);
178 | }
179 | }
180 |
181 | }
182 |
183 | public static void save(Properties props, OutputStream os, String comment,
184 | String encoding) throws IOException {
185 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
186 | DocumentBuilder db = null;
187 | try {
188 | db = dbf.newDocumentBuilder();
189 | } catch (ParserConfigurationException parserconfigurationexception) {
190 | }
191 | Document doc = db.newDocument();
192 | Element properties = (Element) doc.appendChild(doc
193 | .createElement("properties"));
194 | if (comment != null) {
195 | Element comments = (Element) properties.appendChild(doc
196 | .createElement("comment"));
197 | comments.appendChild(doc.createTextNode(comment));
198 | }
199 | Set> keys = props.keySet();
200 | String key;
201 | Element entry;
202 | for (Iterator> i = keys.iterator(); i.hasNext(); entry
203 | .appendChild(doc.createTextNode(props.getProperty(key)))) {
204 | key = (String) (String) i.next();
205 | entry = (Element) properties
206 | .appendChild(doc.createElement("entry"));
207 | entry.setAttribute("key", key);
208 | }
209 |
210 | emitDocument(doc, os, encoding);
211 | }
212 |
213 | static void emitDocument(Document doc, OutputStream os, String encoding)
214 | throws IOException {
215 | TransformerFactory tf = TransformerFactory.newInstance();
216 | Transformer t = null;
217 | try {
218 | t = tf.newTransformer();
219 | t.setOutputProperty("doctype-system",
220 | "http://java.sun.com/dtd/properties.dtd");
221 | t.setOutputProperty("indent", "yes");
222 | t.setOutputProperty("method", "xml");
223 | t.setOutputProperty("encoding", encoding);
224 | } catch (TransformerConfigurationException transformerconfigurationexception) {
225 | }
226 | DOMSource doms = new DOMSource(doc);
227 | StreamResult sr = new StreamResult(os);
228 | try {
229 | t.transform(doms, sr);
230 | } catch (TransformerException te) {
231 | IOException ioe = new IOException();
232 | ioe.initCause(te);
233 | throw ioe;
234 | }
235 | }
236 |
237 | }
238 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/OverwriteCaret.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.awt.Graphics;
4 | import java.awt.Rectangle;
5 |
6 | import javax.swing.plaf.TextUI;
7 | import javax.swing.text.BadLocationException;
8 | import javax.swing.text.DefaultCaret;
9 | import javax.swing.text.JTextComponent;
10 |
11 | public class OverwriteCaret extends DefaultCaret {
12 |
13 | public OverwriteCaret() {
14 | }
15 |
16 | protected synchronized void damage(Rectangle r) {
17 | if (r != null)
18 | try {
19 | JTextComponent comp = getComponent();
20 | TextUI mapper = comp.getUI();
21 | Rectangle r2 = mapper.modelToView(comp, getDot() + 1);
22 | int width = r2.x - r.x;
23 | if (width == 0)
24 | width = 8;
25 | comp.repaint(r.x, r.y, width, r.height);
26 | x = r.x;
27 | y = r.y;
28 | this.width = width;
29 | height = r.height;
30 | } catch (BadLocationException badlocationexception) {
31 | }
32 | }
33 |
34 | public void paint(Graphics g) {
35 | if (isVisible())
36 | try {
37 | JTextComponent comp = getComponent();
38 | TextUI mapper = comp.getUI();
39 | Rectangle r1 = mapper.modelToView(comp, getDot());
40 | Rectangle r2 = mapper.modelToView(comp, getDot() + 1);
41 | g = g.create();
42 | g.setColor(comp.getForeground());
43 | g.setXORMode(comp.getBackground());
44 | int width = r2.x - r1.x;
45 | if (width == 0)
46 | width = 8;
47 | g.fillRect(r1.x, r1.y, width, r1.height);
48 | g.dispose();
49 | } catch (BadLocationException badlocationexception) {
50 | }
51 | }
52 |
53 | private static final long serialVersionUID = 1L;
54 | protected static final int MIN_WIDTH = 8;
55 | }
56 |
--------------------------------------------------------------------------------
/src/de/FBEditor/struct/SIDLogin.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.struct;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.math.BigInteger;
5 | import java.net.MalformedURLException;
6 | import java.net.URL;
7 | import java.security.MessageDigest;
8 | import java.security.NoSuchAlgorithmException;
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 | import java.util.regex.Matcher;
12 | import java.util.regex.Pattern;
13 |
14 | import de.FBEditor.utils.Debug;
15 |
16 | public class SIDLogin {
17 |
18 | private static boolean sidLogin;
19 | private static boolean sidLoginLua;
20 | @SuppressWarnings("unused")
21 | private static boolean nLoginLua; // 25.06.2018
22 | private static boolean isLoginOld;
23 | private static boolean isLogOut;
24 | private static String sessionId;
25 | private static String TsessionId;
26 | private static String sidResponse;
27 | private final static String LOGIN_SID_XML = "/cgi-bin/webcm"; // 01.03.2014
28 | private final static String LOGIN_SID_LUA = "/login_sid.lua";
29 | private final static String POSTDATA_LOGIN_SID_LUA_RESPONSE = "page=/login_sid.lua&response=";
30 | private final static String POSTDATA_LOGIN_XML = "getpage=../html/login_sid.xml";
31 | private final static String POSTDATA_LOGIN_XML_RESPONSE = "getpage=../html/login_sid.xml&login:command/response=";
32 | private final static String PATTERN_WRITE_ACCESS = "([^<]*)";
33 | private final static String PATTERN_CHALLENGE = "([^<]*)";
34 | private final static String PATTERN_SID = "([^<]*)";
35 | private final static String PATTERN_SID2 = "sid=([^[0-9a-fA-F]<]*)";
36 | private static SIDLogin INSTANCE;
37 | private static String UrlLogoutFB = "";
38 |
39 | public SIDLogin() {
40 | sidLogin = false;
41 | sidLoginLua = false;
42 | nLoginLua = false; // 25.06.2018
43 | isLoginOld = false;
44 | isLogOut = false;
45 | sessionId = "0000000000000000";
46 | TsessionId = "0000000000000000";
47 | sidResponse = "";
48 | // UrlLogoutFB = "";
49 | INSTANCE = null;
50 | }
51 |
52 | public static void Login(String box_name, String urlstr,
53 | String box_password, String box_username, String sRetSID) {
54 |
55 | check(box_name, urlstr, box_password, box_username, sRetSID);
56 |
57 | }
58 |
59 | public static void LoginLua(String box_name, String urlstr,
60 | String box_password, String box_username, String sRetSID) { // 25.06.2018
61 |
62 | nLoginLua = true; // 25.06.2018
63 | checkLua(box_name, urlstr, box_password, box_username, sRetSID);
64 |
65 | }
66 |
67 | public static void check(String box_name, String urlstr,
68 | String box_password, String box_username, String sRetSID) {
69 |
70 | try {
71 | isLoginOld = false;
72 | sidLogin = false;
73 | sidLoginLua = false;
74 | //
75 | // urlstr = "http://" + "192.168.178.1" + "/cgi-bin/webcm";
76 | // box_password = "0000";
77 | URL Url2 = new URL(urlstr);
78 | UrlLogoutFB = Url2.getProtocol() + "://" + Url2.getHost()
79 | + "/cgi-bin/webcm";
80 | String sUrl = Url2.getProtocol() + "://" + Url2.getHost() + "";
81 | String sPostdata = "";
82 |
83 | HttpPost http = new HttpPost(); // 23.11.2012
84 | TsessionId = "1 --- " + urlstr;
85 |
86 | // String login_xml = http.Post(urlstr, "sid=" + sRetSID + "&"
87 | // + POSTDATA_LOGIN_XML); // 23.11.2012
88 | String login_xml = http.Post(sUrl + LOGIN_SID_XML, "sid=" + sRetSID
89 | + "&" + POSTDATA_LOGIN_XML); // 01.03.2014
90 | TsessionId = "1";
91 | Pattern writeAccessPattern = Pattern.compile(PATTERN_WRITE_ACCESS);
92 | Matcher matcher = writeAccessPattern.matcher(login_xml);
93 | if (matcher.find()) {
94 |
95 | int writeAccess = Integer.parseInt(matcher.group(1));
96 |
97 | if (writeAccess == 0) { // answer challenge
98 | // try {
99 | String challenge = "";
100 | Pattern challengePattern = Pattern
101 | .compile(PATTERN_CHALLENGE);
102 | Matcher challengeMatcher = challengePattern
103 | .matcher(login_xml);
104 | if (challengeMatcher.find()) {
105 | challenge = challengeMatcher.group(1);
106 | TsessionId = "1 -> " + challenge;
107 | // replace all unicodecharacters greater than 255 with
108 | // the character '.'
109 | for (int i = 0; i < box_password.length(); i++) {
110 | int codePoint = box_password.codePointAt(i);
111 | if (codePoint > 255) {
112 | box_password = box_password.substring(0, i)
113 | + '.' + box_password.substring(i + 1);
114 | }
115 | }
116 |
117 | String pwd = challenge + "-" + box_password;
118 |
119 | MessageDigest m = null;
120 | try {
121 | m = MessageDigest.getInstance("MD5");
122 | } catch (NoSuchAlgorithmException ex) {
123 | Logger.getLogger(SIDLogin.class.getName()).log(
124 | Level.SEVERE, null, ex);
125 | }
126 | String md5Pass = "";
127 | // byte passwordBytes[] = null;
128 | byte[] passwordBytes = new byte[0]; // 30.10.2012
129 | try {
130 | passwordBytes = pwd.getBytes("UTF-16LE");
131 | m.update(passwordBytes, 0, passwordBytes.length);
132 | md5Pass = new BigInteger(1, m.digest())
133 | .toString(16);
134 | } catch (UnsupportedEncodingException e) {
135 | Debug.error("UTF-16LE encoding not supported by your system. Can not communicate with FRITZ!Box!");
136 | }
137 |
138 | sidResponse = challenge + '-' + md5Pass;
139 | TsessionId = "1 -> " + sidResponse;
140 | // Debug.debug("Challenge: " + challenge + " Response: "
141 | // + sidResponse);
142 |
143 | // login_xml = http.Post(urlstr, "sid=" + sRetSID + "&"
144 | // + POSTDATA_LOGIN_XML_RESPONSE + sidResponse); //
145 | // 22.11.2012
146 | login_xml = http.Post(sUrl + LOGIN_SID_XML, "sid="
147 | + sRetSID + "&" + POSTDATA_LOGIN_XML_RESPONSE
148 | + sidResponse); // 01.03.2014
149 |
150 | // Debug.debug("login_xml Response: " + login_xml);
151 |
152 | writeAccessPattern = Pattern
153 | .compile(PATTERN_WRITE_ACCESS);
154 | Matcher matcher1 = writeAccessPattern
155 | .matcher(login_xml);
156 |
157 | // 01.03.2014
158 | Pattern sidPattern = Pattern.compile(PATTERN_SID);
159 | Matcher sidMatcher = sidPattern.matcher(login_xml);
160 |
161 | if (matcher1.find()) {
162 |
163 | writeAccess = Integer.parseInt(matcher1.group(1));
164 |
165 | if (writeAccess == 1) { // answer Response
166 |
167 | // 01.03.2014
168 | // Pattern sidPattern = Pattern
169 | // .compile(PATTERN_SID);
170 | // Matcher sidMatcher = sidPattern
171 | // .matcher(login_xml);
172 |
173 | if (sidMatcher.find()) {
174 | sidLogin = true;
175 | sessionId = sidMatcher.group(1);
176 | TsessionId = "1s -> " + sessionId;
177 | // sRetSID = sessionId; // 18.10.2012
178 | // Debug.debug("login_xml sessionId Response: "
179 | // + sessionId);
180 | }
181 |
182 | } else {
183 | if (sidMatcher.find()) {
184 | sessionId = sidMatcher.group(1); // 01.03.2014
185 | TsessionId = "1s0 -> " + sessionId;
186 | }
187 | sidLogin = false;
188 | }
189 |
190 | }
191 |
192 | // Debug.debug("Challenge: " + challenge + " Response: "
193 | // + sidResponse);
194 | } else {
195 | // Debug.error("Could not determine challenge in login_sid.xml");
196 | }
197 | // } catch (NoSuchAlgorithmException e) {
198 | // Debug.netMsg("MD5 Algorithm not present in this JVM!");
199 | // Debug.error(e.toString());
200 | // e.printStackTrace();
201 | // }
202 | } else if (writeAccess == 1) { // no challenge, use SID directly
203 | Pattern sidPattern = Pattern.compile(PATTERN_SID);
204 | Matcher sidMatcher = sidPattern.matcher(login_xml);
205 | if (sidMatcher.find()) {
206 | sidLogin = true;
207 | sessionId = sidMatcher.group(1);
208 | TsessionId = "2s -> " + sessionId;
209 | }
210 | } else {
211 | // Debug.error("Could not determine writeAccess in login_sid.xml");
212 | }
213 | // Debug.errDlg(Integer.toString(writeAccess) + " " +
214 | // sessionId);
215 | } else {
216 | // 01.03.2014 sidLogin = false;
217 | // 01.03.2014 sidLoginLua = false;
218 |
219 | login_xml = http.Post(sUrl + LOGIN_SID_LUA, "sid=" + sRetSID); // 23.11.2012
220 | // System.out.println(login_xml);
221 | TsessionId = "3";
222 | Pattern SIDwriteAccessPattern = Pattern.compile(PATTERN_SID);
223 | Matcher matcherSID = SIDwriteAccessPattern.matcher(login_xml);
224 |
225 | if (matcherSID.find()) {
226 |
227 | String SIDwriteAccess = matcherSID.group(1);
228 |
229 | if ("0000000000000000".equals(SIDwriteAccess)) { // answer
230 | // challenge
231 | String challenge = "";
232 | Pattern challengePattern = Pattern
233 | .compile(PATTERN_CHALLENGE);
234 | Matcher challengeMatcher = challengePattern
235 | .matcher(login_xml);
236 | if (challengeMatcher.find()) {
237 | challenge = challengeMatcher.group(1);
238 | TsessionId = "3 -> " + challenge;
239 | // replace all unicodecharacters greater than 255
240 | // with
241 | // the character '.'
242 | for (int i = 0; i < box_password.length(); i++) {
243 | int codePoint = box_password.codePointAt(i);
244 | if (codePoint > 255) {
245 | box_password = box_password.substring(0, i)
246 | + '.'
247 | + box_password.substring(i + 1);
248 | }
249 | }
250 |
251 | String pwd = challenge + "-" + box_password;
252 |
253 | MessageDigest m = null;
254 | try {
255 | m = MessageDigest.getInstance("MD5");
256 | } catch (NoSuchAlgorithmException ex) {
257 | Logger.getLogger(SIDLogin.class.getName()).log(
258 | Level.SEVERE, null, ex);
259 | }
260 | String md5Pass = "";
261 | byte[] passwordBytes = new byte[0]; // 30.10.2012
262 | try {
263 | passwordBytes = pwd.getBytes("UTF-16LE");
264 | m.update(passwordBytes, 0, passwordBytes.length);
265 | md5Pass = new BigInteger(1, m.digest())
266 | .toString(16);
267 | } catch (UnsupportedEncodingException ex) {
268 | Logger.getLogger(SIDLogin.class.getName()).log(
269 | Level.SEVERE, null, ex);
270 | }
271 |
272 | sidResponse = challenge + '-' + md5Pass;
273 | TsessionId = "3 -> " + sidResponse;
274 | // 01.03.2014 Debug.debug("Challenge: " + challenge
275 | // 01.03.2014 + " Response: " + sidResponse);
276 |
277 | // sPostdata = POSTDATA_LOGIN_SID_LUA_RESPONSE
278 | // + sidResponse;
279 | sPostdata = POSTDATA_LOGIN_SID_LUA_RESPONSE
280 | + sidResponse + "&username=" + box_username;
281 | login_xml = http.Post(sUrl + LOGIN_SID_LUA,
282 | sPostdata);
283 |
284 | // System.out.println("Login: " + " " +
285 | // login_xml);
286 | // 01.03.2014 Debug.debug("login_lua Response: " + login_xml);
287 | // 01.03.2014 Debug.debug("login_lua Username: " + box_username);
288 |
289 | SIDwriteAccessPattern = Pattern
290 | .compile(PATTERN_SID);
291 | Matcher matcher1 = SIDwriteAccessPattern
292 | .matcher(login_xml);
293 |
294 | if (matcher1.find()) {
295 |
296 | SIDwriteAccess = matcher1.group(1);
297 |
298 | // Debug.debug("login_lua SIDwriteAccesse: " +
299 | // SIDwriteAccess);
300 |
301 | if (!"0000000000000000".equals(SIDwriteAccess)) { // answer
302 | // Response
303 |
304 | Pattern sidPattern = Pattern
305 | .compile(PATTERN_SID);
306 | Matcher sidMatcher = sidPattern
307 | .matcher(login_xml);
308 |
309 | if (sidMatcher.find()) {
310 | sidLogin = true;
311 | sidLoginLua = true;
312 | sessionId = sidMatcher.group(1);
313 | TsessionId = "3s -> " + sessionId;
314 | // 01.03.2014 Debug.debug("login_lua sessionId Response: "
315 | // 01.03.2014 + sessionId);
316 | }
317 |
318 | } else {
319 | sessionId = SIDwriteAccess; // 01.03.2014
320 | TsessionId = "3s0 -> " + sessionId;
321 | sidLogin = false;
322 | sidLoginLua = false;
323 | }
324 | }
325 |
326 | // Debug.debug("Challenge: " + challenge +
327 | // " Response: " + sidResponse);
328 | } else {
329 | // Debug.error("Could not determine challenge in login_sid.xml");
330 | }
331 |
332 | } else if (!"0000000000000000".equals(SIDwriteAccess)) { // no
333 | // challenge,
334 | // use
335 | // SID
336 | // directly
337 | Pattern sidPattern = Pattern.compile(PATTERN_SID);
338 | Matcher sidMatcher = sidPattern.matcher(login_xml);
339 | if (sidMatcher.find()) {
340 | sidLogin = true;
341 | sidLoginLua = true;
342 | sessionId = sidMatcher.group(1);
343 | TsessionId = "4s -> " + sessionId;
344 | }
345 | } else {
346 | Debug.error("Could not determine SIDwriteAccess in login_sid.lua");
347 | }
348 | // Debug.errDlg(SIDwriteAccess + " " + sessionId);
349 |
350 | } else {
351 | sidLogin = false;
352 | sidLoginLua = false;
353 | sessionId = "0000000000000000"; // 01.03.2014
354 | TsessionId = "1 -> 1";
355 |
356 | sPostdata = "getpage=../html/de/menus/menu2.html&login:command/password="
357 | + box_password;
358 | // login_xml = http.Post( urlstr, sPostdata); // 23.11.2012
359 | login_xml = http.Post(sUrl + "/cgi-bin/webcm", sPostdata); // 23.11.2012
360 |
361 | if ("".equals(login_xml)) {
362 | isLoginOld = true; // sidLogin = true;
363 | } else { // 01.03.2014
364 | isLoginOld = false; // sidLogin = false;
365 | }
366 | // System.out.println("Login: " + isLoginOld + " " +
367 | // login_xml);
368 | TsessionId = "1 -> 2";
369 | }
370 |
371 | }
372 |
373 | } catch (MalformedURLException ex) {
374 | Logger.getLogger(SIDLogin.class.getName()).log(Level.SEVERE, null,
375 | ex);
376 | }
377 | }
378 |
379 | public static void checkLua(String box_name, String urlstr,
380 | String box_password, String box_username, String sRetSID) { // 25.06.2018
381 |
382 | try {
383 | isLoginOld = false;
384 | sidLogin = false;
385 | sidLoginLua = false;
386 | //
387 | // urlstr = "http://" + "192.168.178.1" + "/cgi-bin/webcm";
388 | // box_password = "0000";
389 | URL Url2 = new URL(urlstr);
390 | UrlLogoutFB = Url2.getProtocol() + "://" + Url2.getHost()
391 | + "/cgi-bin/webcm";
392 | String sUrl = Url2.getProtocol() + "://" + Url2.getHost() + "";
393 | String sPostdata = "";
394 |
395 | HttpPost http = new HttpPost(); // 23.11.2012
396 | TsessionId = "1 --- " + urlstr;
397 | // 01.03.2014 sidLogin = false;
398 | // 01.03.2014 sidLoginLua = false;
399 |
400 | String login_xml = http.Post(sUrl + LOGIN_SID_LUA, "sid=" + sRetSID); // 23.11.2012
401 | // System.out.println(login_xml);
402 | TsessionId = "3";
403 | Pattern SIDwriteAccessPattern = Pattern.compile(PATTERN_SID);
404 | Matcher matcherSID = SIDwriteAccessPattern.matcher(login_xml);
405 |
406 | if (matcherSID.find()) {
407 |
408 | String SIDwriteAccess = matcherSID.group(1);
409 |
410 | if ("0000000000000000".equals(SIDwriteAccess)) { // answer
411 | // challenge
412 | String challenge = "";
413 | Pattern challengePattern = Pattern
414 | .compile(PATTERN_CHALLENGE);
415 | Matcher challengeMatcher = challengePattern
416 | .matcher(login_xml);
417 | if (challengeMatcher.find()) {
418 | challenge = challengeMatcher.group(1);
419 | TsessionId = "3 -> " + challenge;
420 | // replace all unicodecharacters greater than 255
421 | // with
422 | // the character '.'
423 | for (int i = 0; i < box_password.length(); i++) {
424 | int codePoint = box_password.codePointAt(i);
425 | if (codePoint > 255) {
426 | box_password = box_password.substring(0, i)
427 | + '.'
428 | + box_password.substring(i + 1);
429 | }
430 | }
431 |
432 | String pwd = challenge + "-" + box_password;
433 |
434 | MessageDigest m = null;
435 | try {
436 | m = MessageDigest.getInstance("MD5");
437 | } catch (NoSuchAlgorithmException ex) {
438 | Logger.getLogger(SIDLogin.class.getName()).log(
439 | Level.SEVERE, null, ex);
440 | }
441 | String md5Pass = "";
442 | byte[] passwordBytes = new byte[0]; // 30.10.2012
443 | try {
444 | passwordBytes = pwd.getBytes("UTF-16LE");
445 | m.update(passwordBytes, 0, passwordBytes.length);
446 | md5Pass = new BigInteger(1, m.digest())
447 | .toString(16);
448 | } catch (UnsupportedEncodingException ex) {
449 | Logger.getLogger(SIDLogin.class.getName()).log(
450 | Level.SEVERE, null, ex);
451 | }
452 |
453 | sidResponse = challenge + '-' + md5Pass;
454 | TsessionId = "3 -> " + sidResponse;
455 | // 01.03.2014 Debug.debug("Challenge: " + challenge
456 | // 01.03.2014 + " Response: " + sidResponse);
457 |
458 | // sPostdata = POSTDATA_LOGIN_SID_LUA_RESPONSE
459 | // + sidResponse;
460 | sPostdata = POSTDATA_LOGIN_SID_LUA_RESPONSE
461 | + sidResponse + "&username=" + box_username;
462 | login_xml = http.Post(sUrl + LOGIN_SID_LUA,
463 | sPostdata);
464 |
465 | // System.out.println("Login: " + " " +
466 | // login_xml);
467 | // 01.03.2014 Debug.debug("login_lua Response: " + login_xml);
468 | // 01.03.2014 Debug.debug("login_lua Username: " + box_username);
469 |
470 | SIDwriteAccessPattern = Pattern
471 | .compile(PATTERN_SID);
472 | Matcher matcher1 = SIDwriteAccessPattern
473 | .matcher(login_xml);
474 |
475 | if (matcher1.find()) {
476 |
477 | SIDwriteAccess = matcher1.group(1);
478 |
479 | // Debug.debug("login_lua SIDwriteAccesse: " +
480 | // SIDwriteAccess);
481 |
482 | if (!"0000000000000000".equals(SIDwriteAccess)) { // answer
483 | // Response
484 |
485 | Pattern sidPattern = Pattern
486 | .compile(PATTERN_SID);
487 | Matcher sidMatcher = sidPattern
488 | .matcher(login_xml);
489 |
490 | if (sidMatcher.find()) {
491 | sidLogin = true;
492 | sidLoginLua = true;
493 | sessionId = sidMatcher.group(1);
494 | TsessionId = "3s -> " + sessionId;
495 | // 01.03.2014 Debug.debug("login_lua sessionId Response: "
496 | // 01.03.2014 + sessionId);
497 | }
498 |
499 | } else {
500 | sessionId = SIDwriteAccess; // 01.03.2014
501 | TsessionId = "3s0 -> " + sessionId;
502 | sidLogin = false;
503 | sidLoginLua = false;
504 | nLoginLua = false; // 25.06.2018
505 | }
506 | }
507 |
508 | // Debug.debug("Challenge: " + challenge +
509 | // " Response: " + sidResponse);
510 | } else {
511 | // Debug.error("Could not determine challenge in login_sid.xml");
512 | }
513 |
514 | } else if (!"0000000000000000".equals(SIDwriteAccess)) { // no
515 | // challenge,
516 | // use
517 | // SID
518 | // directly
519 | Pattern sidPattern = Pattern.compile(PATTERN_SID);
520 | Matcher sidMatcher = sidPattern.matcher(login_xml);
521 | if (sidMatcher.find()) {
522 | sidLogin = true;
523 | sidLoginLua = true;
524 | sessionId = sidMatcher.group(1);
525 | TsessionId = "4s -> " + sessionId;
526 | }
527 | } else {
528 | Debug.error("Could not determine SIDwriteAccess in login_sid.lua");
529 | }
530 | // Debug.errDlg(SIDwriteAccess + " " + sessionId);
531 | }
532 |
533 | } catch (MalformedURLException ex) {
534 | Logger.getLogger(SIDLogin.class.getName()).log(Level.SEVERE, null,
535 | ex);
536 | }
537 | }
538 |
539 | public static String getTsessionId() {
540 | return TsessionId;
541 | }
542 |
543 | public static boolean isLogin() {
544 | return isLoginOld;
545 | }
546 |
547 | public static boolean isSidLogin() {
548 | return sidLogin;
549 | }
550 |
551 | public static boolean isSidLoginLua() {
552 | return sidLoginLua;
553 | }
554 |
555 | public static String getResponse() {
556 | return sidResponse;
557 | }
558 |
559 | public static String getSessionId() {
560 | return sessionId;
561 | }
562 |
563 | public static boolean Logout() {
564 | // "Von der Benutzeroberfläche abmelden"
565 |
566 | URL Url2;
567 | String sUrl = "";
568 | try {
569 | Url2 = new URL(UrlLogoutFB);
570 | // UrlLogoutFB = Url2.getProtocol() + "://" + Url2.getHost() +
571 | // "/cgi-bin/webcm";
572 | sUrl = Url2.getProtocol() + "://" + Url2.getHost() + "";
573 | } catch (MalformedURLException ex) {
574 | Logger.getLogger(SIDLogin.class.getName()).log(Level.SEVERE, null,
575 | ex);
576 | }
577 |
578 | HttpPost http = new HttpPost(); // 23.11.2012
579 | String login_xml = "";
580 | isLogOut = false;
581 |
582 | if (sidLogin == true) {
583 |
584 | // 01.03.2014
585 | if (sidLoginLua == true) {
586 |
587 | login_xml = http.Post(sUrl + "/logout.lua", "sid=" + sessionId
588 | + "&logout=1"); // 23.11.2012
589 | // Debug.debug("LogOut: " + login_xml);
590 |
591 | if ("".equals(login_xml)) {
592 | sessionId = "0000000000000000";
593 | sidLogin = false;
594 | sidLoginLua = false;
595 | isLoginOld = false;
596 | isLogOut = true;
597 | // Debug.debug("LogOut1: " + sessionId);
598 |
599 | } else {
600 |
601 | Pattern sidPattern = Pattern.compile(PATTERN_SID2);
602 | Matcher sidMatcher = sidPattern.matcher(login_xml);
603 | if (sidMatcher.find()) {
604 | sessionId = sidMatcher.group(1);
605 | if (!"0000000000000000".equals(sessionId)) {
606 | sidLogin = true;
607 | sidLoginLua = true;
608 | isLoginOld = false;
609 | isLogOut = false;
610 | } else {
611 | sessionId = "0000000000000000";
612 | sidLogin = false;
613 | sidLoginLua = false;
614 | isLoginOld = false;
615 | isLogOut = true;
616 | }
617 | // Debug.debug("LogOut2: " + sessionId);
618 | }
619 |
620 | }
621 |
622 | } else {
623 |
624 | login_xml = http
625 | .Post(UrlLogoutFB,
626 | "sid="
627 | + sessionId
628 | + "&security:command/logout=&getpage=../html/confirm_logout.html"); // 23.11.2012
629 |
630 | if ("".equals(login_xml)) {
631 | sessionId = "0000000000000000";
632 | sidLogin = false;
633 | sidLoginLua = false;
634 | isLoginOld = false;
635 | isLogOut = true;
636 | // Debug.debug("LogOut3: " + sessionId);
637 | }
638 | }
639 |
640 | } else if (isLoginOld == true) {
641 |
642 | login_xml = http.Post(UrlLogoutFB,
643 | "getpage=../html/de/menus/menu2.html&security:command/logout="
644 | + "1"); // 23.11.2012
645 |
646 | if ("".equals(login_xml)) {
647 | sessionId = "0000000000000000";
648 | sidLogin = false;
649 | sidLoginLua = false;
650 | isLoginOld = false;
651 | isLogOut = true;
652 | }
653 | }
654 | return sidLogin;
655 | }
656 |
657 | public static boolean isLogout() {
658 | return isLogOut;
659 | }
660 |
661 | public SIDLogin getInstance() {
662 | if (INSTANCE == null) {
663 | INSTANCE = new SIDLogin();
664 | }
665 | return INSTANCE;
666 | }
667 | }
668 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/CalcChecksum.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.util.regex.Matcher;
5 | import java.util.regex.Pattern;
6 | import java.util.zip.CRC32;
7 | import org.apache.commons.codec.binary.Base64;
8 |
9 | public class CalcChecksum {
10 |
11 | private static int type = 0;
12 | private static boolean file = false;
13 | private static CRC32 crc;
14 | private static String expected = "";
15 | private static String last;
16 |
17 | public CalcChecksum() {
18 | /* Initialize crc32 */
19 | crc = new CRC32();
20 | }
21 |
22 | private void calchk(String line) {
23 | /* start of new section? */
24 | if (type == 0) {
25 | // Debug.debug(Long.toHexString(crc.getValue()));
26 |
27 | String filename;
28 | if ((filename = Utils.pMatch("\\*\\*\\*\\* CFGFILE:(.*?)$", line, 1)) != null) {
29 | Debug.debug(line);
30 | file = true;
31 | type = 1;
32 | } else if ((filename = Utils.pMatch("\\*\\*\\*\\* BINFILE:(.*?)$", line, 1)) != null) {
33 | file = true;
34 | Debug.debug(line);
35 | type = 2;
36 | } else if ((filename = Utils.pMatch("\\*\\*\\*\\* CRYPTEDBINFILE:(.*?)$", line, 1)) != null) {
37 | file = true;
38 | Debug.debug(line);
39 | type = 4;
40 | // CRYPTEDBINFILE bin file 19.04.2015
41 | } else if ((filename = Utils.pMatch("\\*\\*\\*\\* B64FILE:(.*?)$", line, 1)) != null) {
42 | file = true;
43 | Debug.debug(line);
44 | type = 5;
45 | } else {
46 | if (Utils.pMatch("\\*\\*\\*\\* (.+) CONFIGURATION EXPORT", line, 0) != null) {
47 | file = false;
48 | Debug.debug(line);
49 | type = 3;
50 | return;
51 | }
52 | if (Utils.pMatch("\\*\\*\\*\\* END OF EXPORT (.*?)", line, 0) != null) {
53 | expected = line.substring(19, 27);
54 | Debug.debug(line);
55 | }
56 | }
57 | // parse filename
58 | if (file) {
59 | line = filename + '\0';
60 | updateCRC(line);
61 | file = false;
62 | return;
63 | }
64 | } else {
65 | if (type == 1) { // cfg file (stripcslashes, add '\n' at the end)
66 | if (line.indexOf("**** END OF FILE") == 0) {
67 | type = 0;
68 | if (last != null) {
69 | updateCRC(last);
70 | }
71 | last = null;
72 | return;
73 | }
74 | if (last != null) {
75 | last = last.replace("\\\\", "\\");
76 | last = last + '\n';
77 | updateCRC(last);
78 | }
79 | last = line;
80 | return;
81 | }
82 | if (type == 2) { // bin file
83 | if (line.indexOf("**** END OF FILE") == 0) {
84 | type = 0;
85 | return;
86 | }
87 | String hex = line.trim().toLowerCase().replace("\n", "");
88 | String bin_line = "";
89 | for (int i = 0; i < hex.length(); i += 2) {
90 | //int b = Integer.parseInt(hex.substring(i, i + 2), 16);
91 |
92 | // FIXME: This is very slow!
93 | //updateCRC(b);
94 | bin_line += (char) Integer.parseInt(hex.substring(i, i + 2), 16);
95 | }
96 | updateCRC(bin_line);
97 |
98 | return;
99 | }
100 | if (type == 4) { // CRYPTEDBINFILE bin file 19.04.2015
101 | if (line.indexOf("**** END OF FILE") == 0) {
102 | type = 0;
103 | return;
104 | }
105 | String hex = line.trim().toLowerCase().replace("\n", "");
106 | String bin_line = "";
107 | for (int i = 0; i < hex.length(); i += 2) {
108 | bin_line += (char) Integer.parseInt(hex.substring(i, i + 2), 16);
109 | }
110 | updateCRC(bin_line);
111 |
112 | return;
113 | }
114 | if (type == 5) { // base64 file
115 | if (line.indexOf("**** END OF FILE") == 0) {
116 | type = 0;
117 | return;
118 | }
119 | String base64 = line.trim().replace("\n", "");
120 | byte[] dec = Base64.decodeBase64(base64.getBytes());
121 | crc.update(dec);
122 |
123 | return;
124 | }
125 | if (type == 3) { // variable (remove "=", add '\0' to the end
126 | if (line.indexOf("****") != -1) {
127 | type = 0;
128 | calchk(line);
129 | }
130 | if (Utils.pMatch("(\\S*?)=(\\S*?)", line, 0) != null) {
131 | line = line.replaceFirst("=", "");
132 | line = line + '\0';
133 | updateCRC(line);
134 | return;
135 | } else {
136 | return;
137 | }
138 | }
139 | }
140 | }
141 |
142 | public long getChecksum(String text) {
143 | text = text.replace("\r", ""); // Remove all CRs for calculation
144 | Pattern p = Pattern.compile("(.*?)\\n", 2);
145 | for (Matcher matcher = p.matcher(text); matcher.find(); calchk(matcher.group(0).replace("\n", ""))) {
146 | @SuppressWarnings("unused")
147 | String temp = matcher.group(0);
148 | }
149 |
150 | return crc.getValue();
151 | }
152 |
153 | public static boolean getchecksum() {
154 | String checksum = Long.toHexString(crc.getValue()).toUpperCase();
155 | if (checksum.length() < 8)
156 | checksum = '0' + checksum;
157 | if (!checksum.equals(expected)) {
158 | Debug.debug("CHECKSUM FIXED: " + checksum + "(old: " + expected + ")");
159 | return false;
160 | } else {
161 | Debug.debug("CHECKSUM OK: " + checksum);
162 | return true;
163 | }
164 | }
165 |
166 | private void updateCRC(String line) {
167 | try {
168 | crc.update(line.getBytes("ISO-8859-1"));
169 | } catch (UnsupportedEncodingException e) {
170 | // TODO Auto-generated catch block
171 | e.printStackTrace();
172 | }
173 | }
174 | /*
175 | private void updateCRC(int b) {
176 | crc.update(b);
177 | }
178 | */
179 |
180 | /*
181 | * Calculate new checksum and replace if different
182 | */
183 | public static String replaceChecksum(String text) {
184 | String newText = "";
185 | String checksum;
186 | if ((checksum = Utils.pMatch("\\*\\*\\*\\* END OF EXPORT (.*?) \\*\\*\\*\\*", text, 1)) != null) {
187 | CalcChecksum exportsumme = new CalcChecksum();
188 | String newChecksum = Long.toHexString(exportsumme.getChecksum(text));
189 | newChecksum = newChecksum.toUpperCase();
190 | if (!CalcChecksum.getchecksum()) { // 25.07.2020
191 | if (newChecksum.length() < 8)
192 | newChecksum = '0' + newChecksum;
193 | newText = text.replace(checksum, newChecksum);
194 | } else {
195 | newText = text;
196 | }
197 | } else {
198 | newText = text;
199 | }
200 | return newText;
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/Debug.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on 20.05.2005
3 | *
4 | */
5 | package de.FBEditor.utils;
6 |
7 |
8 | import java.io.BufferedReader;
9 | import java.io.FileOutputStream;
10 | import java.io.FileReader;
11 | import java.io.IOException;
12 | import java.io.PrintStream;
13 | import java.text.SimpleDateFormat;
14 | import java.util.Date;
15 |
16 | import javax.swing.JButton;
17 | import javax.swing.JComboBox;
18 | import javax.swing.JPanel;
19 | import javax.swing.JTextArea;
20 |
21 | /**
22 | * Write debug messages to STDOUT or FILE. Show Error-Dialog with a special
23 | * message
24 | *
25 | * 14.05.06 Added support for redirecting System.out and System.err Now all
26 | * exceptions are also included in the debug file Brian Jensen
27 | *
28 | * @author Robert Palmer
29 | *
30 | */
31 | public class Debug {
32 | public static final LogSeverity LS_ALWAYS = new LogSeverity(0, "LS_ALWAYS", "");
33 | public static final LogSeverity LS_ERROR = new LogSeverity(1, "LS_ERROR", ": ERROR");
34 | public static final LogSeverity LS_WARNING = new LogSeverity(2, "LS_WARNING", ": WARNING");
35 | public static final LogSeverity LS_NETWORK = new LogSeverity(3, "LS_NETWORK", ": NETWORK");
36 | public static final LogSeverity LS_INFO = new LogSeverity(4, "LS_INFO", ": INFO");
37 | public static final LogSeverity LS_DEBUG = new LogSeverity(5, "LS_DEBUG", ": DEBUG");
38 |
39 | @SuppressWarnings("unused")
40 | private static final long serialVersionUID = 9211082107025215527L;
41 |
42 | private static LogSeverity debugLevel;
43 | private static String debugLogFile;
44 |
45 | private static boolean verboseMode = false;
46 |
47 | private static PrintStream fileRedirecter, originalOut;
48 |
49 | private static JPanel main_panel = null;
50 |
51 | private static JTextArea log_area;
52 |
53 | private static JButton close_button;
54 | private static JButton save_button;
55 | private static JButton refresh_button;
56 | private static JComboBox> log_severity_box;
57 |
58 | /**
59 | * Turns debug-mode on
60 | *
61 | */
62 | public static void on() {
63 | verboseMode = false;
64 | Debug.debugLevel = LS_DEBUG;
65 | //logToFile("debug.log");
66 | }
67 |
68 | /**
69 | * This function works by redirecting System.out and System.err to fname The
70 | * original console stream is saved as originalout 15.05.06 Brian Jensen
71 | *
72 | * Turn on logging mode to file
73 | *
74 | * @param fName
75 | * Filename to log into
76 | */
77 | public static void logToFile(final String fName) {
78 | debugLogFile = fName;
79 |
80 | // Save the original outputstream so we can write to the console too!
81 | originalOut = System.out;
82 |
83 | try {
84 | // setup the redirection of Sysem.out and System.err
85 | FileOutputStream tmpOutputStream = new FileOutputStream(
86 | debugLogFile);
87 | fileRedirecter = new PrintStream(tmpOutputStream);
88 | System.setOut(fileRedirecter);
89 | System.setErr(fileRedirecter);
90 | }
91 |
92 | catch (Exception e) {
93 | System.err.println("EXCEPTION when writing to LOGFILE"); //$NON-NLS-1$
94 | }
95 | }
96 |
97 | /**
98 | *
99 | * @return current Time HH:mm:ss
100 | */
101 | private static String getCurrentTime() {
102 | Date now = new java.util.Date();
103 | SimpleDateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm:ss"); //$NON-NLS-1$
104 | return df.format(now);
105 | }
106 |
107 | /**
108 | * Print message with prioriry level
109 | *
110 | * @param level
111 | * @param msg
112 | */
113 | private static void msg(LogSeverity level, final String msg) {
114 | if ( (debugLevel == null)
115 | || (debugLevel != null) && (debugLevel.getId() >= level.getId())) {
116 | String message = msg;
117 | message = "(" + getCurrentTime() + ")"+ level.getPrefix() + ": "+ message; //$NON-NLS-1$, //$NON-NLS-2$
118 | System.out.println(message);
119 |
120 | // if both verbose mode and logging enabled, make sure output
121 | // still lands on the console as well!
122 | if (verboseMode) {
123 | originalOut.println(message);
124 | }
125 | }
126 | }
127 |
128 | /**
129 | * This is a modified message function, used by the network subsystem
130 | * so the debug output is more readable
131 | *
132 | * @param msg
133 | */
134 | public static void netMsg(final String msg){
135 | msg(LS_NETWORK, msg);
136 | }
137 |
138 | public static void always(String msg) {
139 | msg(LS_ALWAYS, msg);
140 | }
141 |
142 | public static void error(String msg) {
143 | msg(LS_ERROR, msg);
144 | }
145 |
146 | public static void warning(String msg) {
147 | msg(LS_WARNING, msg);
148 | }
149 |
150 | public static void info(String msg) {
151 | msg(LS_INFO, msg);
152 | }
153 |
154 | public static void debug(String msg) {
155 | msg(LS_DEBUG, msg);
156 | }
157 |
158 | private static void loadDebugFile(){
159 | try {
160 | int selectedLogSeverityIndex = log_severity_box.getSelectedIndex();
161 | LogSeverity selectedLogSeverity = (LogSeverity) log_severity_box.getItemAt(selectedLogSeverityIndex);
162 | log_area.setText("");
163 | @SuppressWarnings("resource")
164 | BufferedReader in = new BufferedReader(new FileReader(debugLogFile));
165 | String zeile = null;
166 | while ((zeile = in.readLine()) != null) {
167 | if (selectedLogSeverity.getId() >= returnLineSeverity(zeile).getId())
168 | {
169 | log_area.append(zeile + "\n");
170 | }
171 | }
172 | } catch (IOException e) {
173 | e.printStackTrace();
174 | }
175 | }
176 |
177 | private static LogSeverity returnLineSeverity(String line)
178 | {
179 | LogSeverity ls = LS_DEBUG;
180 | if (line.substring(19).startsWith(LS_DEBUG.getPrefix())) {
181 | ls = LS_DEBUG;
182 | } else if (line.substring(19).startsWith(LS_INFO.getPrefix())) {
183 | ls = LS_INFO;
184 | } else if (line.substring(19).startsWith(LS_NETWORK.getPrefix())) {
185 | ls = LS_NETWORK;
186 | } else if (line.substring(19).startsWith(LS_WARNING.getPrefix())) {
187 | ls = LS_WARNING;
188 | } else if (line.substring(19).startsWith(LS_ERROR.getPrefix())) {
189 | ls = LS_ERROR;
190 | } else {
191 | ls = LS_ALWAYS;
192 | }
193 |
194 | return ls;
195 | }
196 |
197 | public static JPanel getPanel()
198 | {
199 | loadDebugFile();
200 | return main_panel;
201 | }
202 |
203 | public static void setCloseButtonText(String text)
204 | {
205 | close_button.setText(text);
206 | }
207 |
208 | public static void setSaveButtonText(String text)
209 | {
210 | save_button.setText(text);
211 | }
212 |
213 | public static void setRefreshButtonText(String text)
214 | {
215 | refresh_button.setText(text);
216 | }
217 |
218 | public static void setVerbose(boolean verbose)
219 | {
220 | verboseMode = verbose;
221 | }
222 |
223 | public static void setDebugLevel(LogSeverity level)
224 | {
225 | debugLevel = level;
226 | info("Set debug level to " + level.getName());
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/Encryption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on 08.06.2005
3 | *
4 | */
5 | package de.FBEditor.utils;
6 |
7 | import java.io.ByteArrayOutputStream;
8 | import java.security.Key;
9 | import java.util.StringTokenizer;
10 |
11 | import javax.crypto.Cipher;
12 | import javax.crypto.KeyGenerator;
13 | import javax.crypto.SecretKey;
14 | import javax.crypto.SecretKeyFactory;
15 | import javax.crypto.spec.DESKeySpec;
16 |
17 |
18 | /**
19 | * Encrypting / decrypting of Strings
20 | *
21 | */
22 | public class Encryption {
23 | private static final String KEY_STRING = "193-155-248-97-234-56-100-241"; //$NON-NLS-1$
24 |
25 | public static String encrypt(String source) {
26 | try {
27 | // Get our secret key
28 | Key key = getKey();
29 |
30 | // Create the cipher
31 | Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); //$NON-NLS-1$
32 |
33 | // Initialize the cipher for encryption
34 | desCipher.init(Cipher.ENCRYPT_MODE, key);
35 |
36 | // Our cleartext as bytes
37 | byte[] cleartext = source.getBytes();
38 |
39 | // Encrypt the cleartext
40 | byte[] ciphertext = desCipher.doFinal(cleartext);
41 |
42 | // Return a String representation of the cipher text
43 | return getString(ciphertext);
44 | } catch (Exception e) {
45 | Debug.error(e.toString());
46 | }
47 | return null;
48 | }
49 |
50 | public static String generateKey() {
51 | try {
52 | KeyGenerator keygen = KeyGenerator.getInstance("DES"); //$NON-NLS-1$
53 | SecretKey desKey = keygen.generateKey();
54 | byte[] bytes = desKey.getEncoded();
55 | return getString(bytes);
56 | } catch (Exception e) {
57 | Debug.error(e.toString());
58 | return null;
59 | }
60 | }
61 |
62 | public static String decrypt(final String source) {
63 | try {
64 | String sourceStr = source;
65 | if (sourceStr == null)
66 | sourceStr = "";
67 | // Get our secret key
68 | Key key = getKey();
69 |
70 | // Create the cipher
71 | Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); //$NON-NLS-1$
72 |
73 | // Encrypt the cleartext
74 | byte[] ciphertext = getBytes(sourceStr);
75 |
76 | // Initialize the same cipher for decryption
77 | desCipher.init(Cipher.DECRYPT_MODE, key);
78 |
79 | // Decrypt the ciphertext
80 | byte[] cleartext = desCipher.doFinal(ciphertext);
81 |
82 | // Return the clear text
83 | return new String(cleartext);
84 | } catch (Exception e) {
85 | Debug.error(e.toString());
86 | }
87 | return null;
88 | }
89 |
90 | private static Key getKey() {
91 | try {
92 | byte[] bytes = getBytes(KEY_STRING);
93 | DESKeySpec pass = new DESKeySpec(bytes);
94 | SecretKeyFactory skf = SecretKeyFactory.getInstance("DES"); //$NON-NLS-1$
95 | SecretKey s = skf.generateSecret(pass);
96 | return s;
97 | } catch (Exception e) {
98 | Debug.error(e.toString());
99 | }
100 | return null;
101 | }
102 |
103 | /**
104 | * Returns true if the specified text is encrypted, false otherwise
105 | */
106 | public static boolean isEncrypted(String text) {
107 | // If the string does not have any separators then it is not
108 | // encrypted
109 | if (text.indexOf('-') == -1) {
110 | ///System.out.println( "text is not encrypted: no dashes" );
111 | return false;
112 | }
113 |
114 | StringTokenizer st = new StringTokenizer(text, "-", false); //$NON-NLS-1$
115 | while (st.hasMoreTokens()) {
116 | String token = st.nextToken();
117 | if (token.length() > 3) {
118 | // System.out.println( "text is not encrypted: length of token
119 | // greater than 3: " + token );
120 | return false;
121 | }
122 | for (int i = 0; i < token.length(); i++) {
123 | if (!Character.isDigit(token.charAt(i))) {
124 | // System.out.println( "text is not encrypted: token is not
125 | // a digit" );
126 | return false;
127 | }
128 | }
129 | }
130 | // System.out.println( "text is encrypted" );
131 | return true;
132 | }
133 |
134 | private static String getString(byte[] bytes) {
135 | StringBuffer sb = new StringBuffer();
136 | for (int i = 0; i < bytes.length; i++) {
137 | byte b = bytes[i];
138 | sb.append((int) (0x00FF & b));
139 | if (i + 1 < bytes.length) {
140 | sb.append("-"); //$NON-NLS-1$
141 | }
142 | }
143 | return sb.toString();
144 | }
145 |
146 | private static byte[] getBytes(String str) {
147 | ByteArrayOutputStream bos = new ByteArrayOutputStream();
148 | StringTokenizer st = new StringTokenizer(str, "-", false); //$NON-NLS-1$
149 | while (st.hasMoreTokens()) {
150 | int i = Integer.parseInt(st.nextToken());
151 | bos.write((byte) i);
152 | }
153 | return bos.toByteArray();
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/Listener.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils;
2 |
3 | import java.awt.Component;
4 | import java.awt.event.KeyEvent;
5 | import java.awt.event.KeyListener;
6 | import java.awt.event.MouseAdapter;
7 | import java.awt.event.MouseEvent;
8 | import java.awt.event.WindowEvent;
9 | import java.awt.event.WindowListener;
10 |
11 | import javax.swing.JPopupMenu;
12 | import javax.swing.event.DocumentEvent;
13 | import javax.swing.event.DocumentListener;
14 | import javax.swing.text.JTextComponent;
15 |
16 | import de.FBEditor.CutAndPastePopup;
17 | import de.FBEditor.FBEdit;
18 | import de.FBEditor.FindReplace;
19 | import de.FBEditor.struct.JTextPane2;
20 |
21 | public class Listener {
22 |
23 | public static void addKeyListener(final FBEdit fbedit) {
24 | final JTextPane2 pane2 = fbedit.getJTextPane();
25 |
26 | pane2.addKeyListener(new KeyListener() {
27 |
28 | public void keyTyped(KeyEvent keyevent) {
29 | }
30 |
31 | public void keyPressed(KeyEvent keyevent) {
32 | }
33 |
34 | public void keyReleased(KeyEvent arg0) {
35 | FindReplace findReplace = fbedit.getFindReplace();
36 | int key = arg0.getKeyCode();
37 |
38 | /* Insert Mode */
39 | if (key == 155) {
40 | fbedit.toggleInsertMode();
41 | fbedit.selectCaret(pane2);
42 | }
43 |
44 | /* F3 - Weitersuchen */
45 | if (key == KeyEvent.VK_F3) {
46 | if (findReplace != null)
47 | findReplace.searchon();
48 | }
49 | }
50 | });
51 | }
52 |
53 | public static void addWinListener(final FBEdit fbedit) {
54 | fbedit.addWindowListener(new WindowListener() {
55 |
56 | public void windowOpened(WindowEvent windowevent) {
57 | }
58 |
59 | public void windowClosing(WindowEvent e) {
60 | fbedit.exit();
61 | }
62 |
63 | public void windowClosed(WindowEvent windowevent) {
64 | }
65 |
66 | public void windowIconified(WindowEvent windowevent) {
67 | }
68 |
69 | public void windowDeiconified(WindowEvent windowevent) {
70 | }
71 |
72 | public void windowActivated(WindowEvent windowevent) {
73 | }
74 |
75 | public void windowDeactivated(WindowEvent windowevent) {
76 | }
77 | });
78 | }
79 |
80 | public static DocumentListener myDocumentListener(final FBEdit fbedit) {
81 | DocumentListener myDocumentListener = new DocumentListener() {
82 |
83 | public void insertUpdate(DocumentEvent aEvent) {
84 | fbedit.updateMenu(fbedit.getMenu());
85 | }
86 |
87 | public void removeUpdate(DocumentEvent documentevent) {
88 | }
89 |
90 | public void changedUpdate(DocumentEvent aEvent) {
91 | fbedit.updateMenu(fbedit.getMenu());
92 | }
93 | };
94 |
95 | return myDocumentListener;
96 | }
97 |
98 | public static void addMouseListener(final FBEdit fbedit, final CutAndPastePopup cutAndPastePopup, final JPopupMenu popup ) {
99 |
100 | fbedit.getJTextPane().addMouseListener(new MouseAdapter() {
101 |
102 | public void mousePressed(MouseEvent e) {
103 | if (e.isPopupTrigger()) {
104 | cutAndPastePopup.updateSource((JTextComponent) e.getSource());
105 | cutAndPastePopup.updateMenu();
106 | popup.show((Component) e.getSource(), e.getX(), e.getY());
107 | }
108 | }
109 |
110 | public void mouseReleased(MouseEvent e) {
111 | if (e.isPopupTrigger()) {
112 | cutAndPastePopup.updateSource((JTextComponent) e.getSource());
113 | cutAndPastePopup.updateMenu();
114 | popup.show((Component) e.getSource(), e.getX(), e.getY());
115 | }
116 | }
117 | });
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/LogSeverity.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils;
public class LogSeverity {
private int id;
private String name;
private String prefix;
public LogSeverity(int id, String name, String prefix)
{
this.id = id;
this.name = name;
this.prefix = prefix;
}
public String toString() {
return name;
}
public int getId()
{
return id;
}
public String getName() {
return name;
}
public String getPrefix() {
return prefix;
}
}
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/StringPartNoTransferEncoding.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils;
2 |
3 | import org.apache.commons.httpclient.methods.multipart.StringPart;
4 |
5 | public class StringPartNoTransferEncoding extends StringPart {
6 |
7 | public StringPartNoTransferEncoding(String name, String value) {
8 | super(name, value);
9 | }
10 |
11 | public String getTransferEncoding() {
12 | return null;
13 | }
14 |
15 | public String getContentType() {
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils;
2 |
3 | import static de.FBEditor.FBEdit.fbConnection;
4 |
5 | import java.io.BufferedInputStream;
6 | import java.io.BufferedWriter;
7 | import java.io.File;
8 | import java.io.FileInputStream;
9 | import java.io.FileNotFoundException;
10 | import java.io.FileOutputStream;
11 | import java.io.FileWriter;
12 | import java.io.IOException;
13 | import java.net.InetAddress;
14 | import java.net.InetSocketAddress;
15 | import java.net.Socket;
16 | import java.net.SocketAddress;
17 | import java.util.logging.Level;
18 | import java.util.logging.Logger;
19 | import java.util.regex.Matcher;
20 | import java.util.regex.Pattern;
21 |
22 | import javax.swing.JOptionPane;
23 |
24 | import org.apache.commons.httpclient.HttpClient;
25 | import org.apache.commons.httpclient.methods.PostMethod;
26 | import org.apache.commons.httpclient.methods.multipart.FilePart;
27 | import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
28 | import org.apache.commons.httpclient.methods.multipart.Part;
29 |
30 | import de.FBEditor.FBEdit;
31 | import de.FBEditor.FritzBoxFirmware;
32 | import de.FBEditor.struct.MyProperties;
33 | import de.FBEditor.struct.SIDLogin;
34 |
35 | public class Utils {
36 |
37 | // Check if we can connect to the given host
38 | public static boolean checkhost(String host) throws IOException {
39 | String[] temp;
40 | int port;
41 | Boolean bool = false;
42 |
43 | Pattern p = Pattern.compile(":");
44 | temp = p.split(host);
45 |
46 | InetAddress addr = InetAddress.getByName(temp[0]);
47 | if (temp.length == 2)
48 | port = Integer.valueOf(temp[1]).intValue();
49 | else
50 | port = 80;
51 |
52 | try { // 04.07.2018
53 | SocketAddress sockaddr = new InetSocketAddress(addr, port);
54 | Socket test = new Socket();
55 | int timeoutMs = 1000; // 1 second
56 | test.connect(sockaddr, timeoutMs);
57 | test.close();
58 | bool = true;
59 | } catch (IOException ex) {
60 | System.out.println("Socket test: " + ex);
61 | }
62 | return bool;
63 | }
64 |
65 | public static String pMatch(String s, String s1, int i) {
66 | Pattern pattern = Pattern.compile(s, 2);
67 | Matcher matcher = pattern.matcher(s1);
68 | if (matcher.find())
69 | return matcher.group(i);
70 | else
71 | return null;
72 | }
73 |
74 | public static boolean exportData(FBEdit fbedit, String box_address,
75 | String data) {
76 | boolean result = false;
77 |
78 | // 14.12.2014
79 | FritzBoxFirmware firmware = null;
80 | firmware = fbConnection.getFirmware();
81 | //*
82 | try {
83 | String url = (new StringBuilder("http://")).append(box_address)
84 | .append("/cgi-bin/firmwarecfg").toString();
85 | File uploadFile = createTempFile(data);
86 | //*
87 | PostMethod mPost = new PostMethod(url);
88 |
89 | // Kennwort der Sicherungsdatei
90 | String ConfigImExPwd = "";
91 | /*
92 | String box_ConfigImExPwd = FBEdit.getInstance().getbox_ConfigImExPwd();
93 | System.out.println("box.ConfigImExPwd: " + box_ConfigImExPwd);
94 |
95 | if ( !"".equals(box_ConfigImExPwd) ) {
96 | // Hier kann man ein PopUp Dialog verwenden
97 | // mit der Frage, mit oder ohne Kennwort Speichern
98 |
99 | FBEdit.getInstance().getConfigImExPwd(false);
100 |
101 | if ( FBEdit.isConfigImExPwdOk() == true ) {
102 | box_ConfigImExPwd = FBEdit.getInstance().getbox_ConfigImExPwd();
103 | // ConfigImExPwd = ""; // Abbrechen -> ohne Kennwort
104 | ConfigImExPwd = box_ConfigImExPwd; // OK -> mit Kennwort
105 | }
106 | System.out.println("ConfigImExPwd: " + ConfigImExPwd + " -> " + FBEdit.isConfigImExPwdOk());
107 | }
108 | */
109 |
110 | String sid = SIDLogin.getSessionId();
111 |
112 | Part[] parts = null;
113 | if (SIDLogin.isSidLogin()) {
114 | // with session id
115 | // 14.12.2014 ab Firmware xxx.06.xx with "apply"
116 | if (firmware.getMajorFirmwareVersion() >= 6) { // ab Firmware xxx.06.xx with "apply"
117 | System.out.println("DEBUG: firmware.getMajorFirmwareVersion() >= 6: " + firmware.getMajorFirmwareVersion());
118 | parts = new Part[4];
119 | parts[0] = new StringPartNoTransferEncoding("sid", sid);
120 | //parts[1] = new StringPartNoTransferEncoding(
121 | // "ImportExportPassword", "");
122 | parts[1] = new StringPartNoTransferEncoding(
123 | "ImportExportPassword", ConfigImExPwd);
124 | parts[2] = new FilePart("ConfigImportFile",
125 | uploadFile.getName(), uploadFile);
126 | parts[3] = new StringPartNoTransferEncoding(
127 | "apply", "");
128 | } else {
129 | System.out.println("DEBUG: firmware.getMajorFirmwareVersion(): " + firmware.getMajorFirmwareVersion());
130 | parts = new Part[3];
131 | parts[0] = new StringPartNoTransferEncoding("sid", sid);
132 | //parts[1] = new StringPartNoTransferEncoding(
133 | // "ImportExportPassword", "");
134 | parts[1] = new StringPartNoTransferEncoding(
135 | "ImportExportPassword", ConfigImExPwd);
136 | parts[2] = new FilePart("ConfigImportFile",
137 | uploadFile.getName(), uploadFile);
138 | }
139 | } else {
140 | // old style, no session id
141 | parts = new Part[2];
142 | //parts[0] = new StringPartNoTransferEncoding(
143 | // "ImportExportPassword", "");
144 | parts[0] = new StringPartNoTransferEncoding(
145 | "ImportExportPassword", ConfigImExPwd);
146 | parts[1] = new FilePart("ConfigImportFile",
147 | uploadFile.getName(), uploadFile);
148 | }
149 |
150 | mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost
151 | .getParams()));
152 |
153 | HttpClient client = new HttpClient();
154 | client.getHttpConnectionManager().getParams()
155 | .setConnectionTimeout(8000);
156 |
157 | int statusCode1 = client.executeMethod(mPost);
158 |
159 | BufferedInputStream bis = new BufferedInputStream(
160 | mPost.getResponseBodyAsStream());
161 | byte buf[] = new byte[4096];
162 | StringBuffer sb = new StringBuffer();
163 | int len;
164 | while ((len = bis.read(buf)) > 0)
165 | sb.append(new String(buf, 0, len));
166 | data = HTMLUtil.stripEntities(sb.toString());
167 | data = HTMLUtil.stripNbsp(data);
168 | bis.close();
169 |
170 | if (statusCode1 == 200 && checkResponse(data))
171 | result = true;
172 | else
173 | JOptionPane.showMessageDialog(fbedit, FBEdit.getMessage(""),
174 | FBEdit.getMessage("error"), 0);
175 |
176 | mPost.releaseConnection();
177 | //*/
178 | } catch (IOException ex) {
179 | Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
180 | }
181 | //*/
182 | return result;
183 | }
184 |
185 | public static boolean createDefaultProperties(MyProperties properties) {
186 | // properties = new MyProperties();
187 | // Set Properties Default Values // 22.02.2014
188 | // Muss immer vor Load and Save File aufgerufen werden
189 |
190 | System.out.println("Properties " + "Set" + " using default values");
191 |
192 | properties.setProperty("position.top", "60");
193 | properties.setProperty("position.left", "60");
194 | properties.setProperty("position.height", "480");
195 | properties.setProperty("position.width", "680");
196 |
197 | properties.setProperty("box.address", "fritz.box");
198 | properties.setProperty("box.password", "");
199 | properties.setProperty("box.username", "");
200 | // properties.setProperty("box.ConfigImExPwd", "");
201 | properties.setProperty("readOnStartup", "false"); // 25.06.2018
202 | // properties.setProperty("NoChecks", "true"); // 17.02.2014
203 | properties.setProperty("NoChecks", "false"); // 17.02.2014
204 | properties.setProperty("language", "de_DE");
205 | properties.setProperty("language.setting.manuell", "no"); // 25.06.2018
206 | properties.setProperty("program.start.dialog", "false"); // 25.06.2018
207 | properties.setProperty("box.login.lua", "true"); // 25.06.2018
208 |
209 | return true;
210 | }
211 |
212 | public static boolean loadProperties(MyProperties properties,
213 | String PROPERTIES_FILE) {
214 | // properties = new MyProperties();
215 | try {
216 | FileInputStream fis = new FileInputStream(PROPERTIES_FILE);
217 | properties.loadFromXML(fis);
218 | fis.close();
219 | return true;
220 | } catch (FileNotFoundException e) {
221 | System.out.println("File " + PROPERTIES_FILE
222 | + " not found, using default values");
223 | properties.setProperty("box.address", "fritz.box");
224 | properties.setProperty("box.password", "");
225 | properties.setProperty("box.username", "");
226 | // properties.setProperty("box.ConfigImExPwd", "");
227 | properties.setProperty("readOnStartup", "false"); // 25.06.2018
228 | // properties.setProperty("NoChecks", "true"); // 17.02.2014
229 | properties.setProperty("NoChecks", "false"); // 17.02.2014
230 | properties.setProperty("language", "de_DE");
231 | properties.setProperty("language.setting.manuell", "no"); // 25.06.2018
232 | properties.setProperty("program.start.dialog", "false"); // 25.06.2018
233 | properties.setProperty("box.login.lua", "true"); // 25.06.2018
234 | } catch (Exception exception) {
235 | }
236 | return false;
237 | }
238 |
239 | public static void saveProperties(String PROPERTIES_FILE, FBEdit fbedit) {
240 | MyProperties properties = new MyProperties();
241 | properties.setProperty("position.top",
242 | Integer.toString(fbedit.getLocation().y));
243 | properties.setProperty("position.left",
244 | Integer.toString(fbedit.getLocation().x));
245 | properties.setProperty("position.height",
246 | Integer.toString(fbedit.getSize().height));
247 | properties.setProperty("position.width",
248 | Integer.toString(fbedit.getSize().width));
249 | properties.setProperty("box.address", fbedit.getbox_address());
250 | properties.setProperty("box.password",
251 | Encryption.encrypt(fbedit.getbox_password()));
252 | properties.setProperty("box.username", fbedit.getbox_username());
253 | // properties.setProperty("box.ConfigImExPwd", fbedit.getbox_ConfigImExPwd());
254 | properties.setProperty("readOnStartup", fbedit.getRASstate());
255 | properties.setProperty("NoChecks", fbedit.getNoChecksState());
256 | properties.setProperty("language", fbedit.getLanguage());
257 | properties.setProperty("language.setting.manuell", fbedit.getLanguageManuellState()); // 25.06.2018
258 | properties.setProperty("program.start.dialog", fbedit.getProgramStartDialogState()); // 25.06.2018
259 | properties.setProperty("box.login.lua", fbedit.getBoxLoginLuaState()); // 25.06.2018
260 | try {
261 | FileOutputStream fos = new FileOutputStream(PROPERTIES_FILE);
262 | properties.storeToXML(fos, "Properties for FBEditor");
263 | fos.close();
264 | } catch (FileNotFoundException filenotfoundexception) {
265 | } catch (IOException ioexception) {
266 | }
267 | }
268 |
269 | private static File createTempFile(String data) throws IOException {
270 | // Create temp file.
271 | File temp = File.createTempFile("FRITZ.BOX", ".export");
272 |
273 | // Delete temp file when program exits.
274 | temp.deleteOnExit();
275 |
276 | // Write to temp file
277 | BufferedWriter out = new BufferedWriter(new FileWriter(temp));
278 | out.write(data);
279 | out.close();
280 | return temp;
281 | }
282 |
283 | private static boolean checkResponse(String data) {
284 | return (!data.contains("fehlgeschlagen"));
285 | }
286 |
287 | }
288 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/upnp/MyAuthenticator.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils.upnp;
2 |
3 | import java.net.Authenticator;
4 | //import java.net.InetAddress;
5 | import java.net.PasswordAuthentication;
6 | //import java.net.URL;
7 |
8 | public class MyAuthenticator extends Authenticator {
9 |
10 | private String mUsername = "";
11 | private String mPassword = "";
12 |
13 | // 01.08.2015
14 | public MyAuthenticator(String username, String password) {
15 | mUsername = username;
16 | mPassword = password;
17 | }
18 |
19 | @Override
20 | protected PasswordAuthentication getPasswordAuthentication() {
21 | // String promptString = getRequestingPrompt();
22 | // System.out.println("Authenticator.getRequestingPrompt(): " + promptString);
23 | // String hostname = getRequestingHost();
24 | // System.out.println("Authenticator.getRequestingHost(): " + hostname);
25 | // InetAddress ipaddr = getRequestingSite();
26 | // System.out.println("Authenticator.getRequestingSite(): " + ipaddr);
27 | // int port = getRequestingPort();
28 | // System.out.println("Authenticator.getRequestingPort(): " + port);
29 | // String schemeString = getRequestingScheme();
30 | // System.out.println("Authenticator.getRequestingScheme(): " + schemeString);
31 | // URL URLString = getRequestingURL();
32 | // System.out.println("Authenticator.getRequestingURL(): " + URLString);
33 | // RequestorType typeString = getRequestorType();
34 | // System.out.println("Authenticator.getRequestorType(): " + typeString);
35 | // String protocolString = getRequestingProtocol();
36 | // System.out.println("Authenticator.getRequestingProtocol(): " + protocolString);
37 |
38 | // String username = "name";
39 | // String password = "password";
40 |
41 | return new PasswordAuthentication(mUsername, mPassword.toCharArray());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/de/FBEditor/utils/upnp/UPNPUtils.java:
--------------------------------------------------------------------------------
1 | package de.FBEditor.utils.upnp;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.DataOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStreamReader;
7 | import java.net.Authenticator;
8 | import java.net.HttpURLConnection;
9 | import java.net.URL;
10 | import java.util.regex.Matcher;
11 | import java.util.regex.Pattern;
12 |
13 | import de.FBEditor.FBEdit;
14 | import de.FBEditor.utils.Debug;
15 |
16 | /*
17 | * Created on 22.05.2005
18 | *
19 | */
20 |
21 | /**
22 | * @author Arno Willig
23 | *
24 | * TODO: Bugfix: Exception if no UPNP enabled
25 | */
26 | public class UPNPUtils {
27 |
28 | private static String URL_SERVICE_CREATEURLSID = ":49000/upnp/control/deviceconfig"; // 01.08.2015
29 | private static String URN_SERVICE_CREATEURLSID = "urn:dslforum-org:service:DeviceConfig:1#X_AVM-DE_CreateUrlSID"; // 01.08.2015
30 |
31 | private static String URL_SERVICE_2FA = ":49000/upnp/control/x_auth"; // 27.04.2018
32 | // private static String URL_SERVICE_2FA = ":49443/upnp/control/x_auth"; // 27.04.2018
33 | private static String URN_SERVICE_2FA = "urn:dslforum-org:service:X_AVM-DE_Auth:1#GetInfo"; // 27.04.2018
34 |
35 | private static String protocol = "http";
36 | // private static String protocol = "https";
37 | private static FBEdit fbe;
38 |
39 | public UPNPUtils() {
40 | }
41 |
42 | /**
43 | * function calls the web service specified by the url with the soap
44 | * envelope specified in xml
45 | *
46 | * @param url of the web service
47 | * @param urn
48 | * @param xml soap element to be trasmitted
49 | * @return
50 | */
51 | public static String getSOAPData(String url, String urn, String xml) {
52 |
53 | String data = "";
54 | BufferedReader d = null;
55 | DataOutputStream printout = null;
56 | try {
57 | URL u = new URL(url);
58 |
59 | HttpURLConnection uc = (HttpURLConnection) u.openConnection();
60 | uc.setRequestMethod("POST");
61 |
62 | // 5 Sekunden-Timeout für Verbindungsaufbau
63 | uc.setConnectTimeout(5000);
64 |
65 | uc.setReadTimeout(2000);
66 |
67 | uc.setDoOutput(true);
68 | uc.setDoInput(true);
69 | uc.setUseCaches(false);
70 |
71 | byte[] bytes = xml.getBytes();
72 |
73 | uc.setRequestProperty("HOST", u.getAuthority()); // 14.05.2018
74 | uc.setRequestProperty("USER-AGENT", "AVM UPnP/1.0 Client 1.0");
75 | uc.setRequestProperty("Connection", "Keep-Alive");
76 | uc.setRequestProperty("CONTENT-LENGTH", String.valueOf(bytes.length));
77 | uc.setRequestProperty("CONTENT-TYPE", //$NON-NLS-1$
78 | "text/xml; charset=\"utf-8\""); //$NON-NLS-1$
79 | uc.setRequestProperty("SOAPACTION", urn); //$NON-NLS-1$
80 | uc.setRequestProperty("Connection", "close");
81 |
82 | printout = new DataOutputStream(uc.getOutputStream());
83 | printout.write(bytes);
84 | printout.close();
85 |
86 | if (uc.getResponseCode() == 200) {
87 | //InputStream in = uc.getInputStream();
88 | d = new BufferedReader(new InputStreamReader(uc.getInputStream()));
89 |
90 | String str;
91 | while (null != ((str = d.readLine())))
92 | data += str + "\n";
93 | }
94 |
95 | } catch (IOException e) {
96 | Debug.error(e.toString());
97 | } finally {
98 |
99 | try {
100 | if(d!=null)
101 | d.close();
102 | }catch(IOException ioe){
103 | Debug.error("Error closing Stream");
104 | }
105 |
106 | try {
107 | if(printout!=null)
108 | printout.close();
109 | }catch(IOException ioe){
110 | Debug.error("Error closing Stream");
111 | }
112 | }
113 | return data;
114 | }
115 |
116 | // 01.08.2015 pikachu // 27.04.2018 pikachu
117 | public static String getSOAPDataAuth(FBEdit fbe, String url, String urn, String xml) {
118 |
119 | String data = "";
120 | BufferedReader d = null;
121 | DataOutputStream printout = null;
122 |
123 | //String username = "@CompatMode"; String password = "0000"; // geht nicht
124 | //String username = "boxuser100"; String password = "0000"; // geht nicht
125 | //String username = "test"; String password = "0000"; // geht nur mit Benutzer Login
126 | String username = FBEdit.getInstance().getbox_username(); String password = FBEdit.getInstance().getbox_password(); // geht nur mit Benutzer Login
127 | // System.out.println("password 1: " + password);
128 | // System.out.println("username 1: " + username);
129 |
130 | try {
131 | Authenticator.setDefault(new MyAuthenticator(username, password));
132 | URL u = new URL(url);
133 |
134 | //Debug.info("Result of DeviceConfig getSOAPDataAuth 1: " + u);
135 | //Debug.info("Result of DeviceConfig getSOAPDataAuth u: " + username);
136 | //Debug.info("Result of DeviceConfig getSOAPDataAuth p: " + password);
137 |
138 | HttpURLConnection uc = (HttpURLConnection) u.openConnection();
139 | //uc.setRequestProperty("Authorization", "Basic " + getBasicAuthenticationEncoding(username, password));
140 | uc.setRequestMethod("POST");
141 |
142 | // 5 Sekunden-Timeout für Verbindungsaufbau
143 | uc.setConnectTimeout(5000);
144 |
145 | uc.setReadTimeout(2000);
146 |
147 | uc.setDoOutput(true);
148 | uc.setDoInput(true);
149 | uc.setUseCaches(false);
150 |
151 | byte[] bytes = xml.getBytes();
152 |
153 | uc.setRequestProperty("HOST", u.getAuthority());
154 | uc.setRequestProperty("USER-AGENT", "AVM UPnP/1.0 Client 1.0");
155 | uc.setRequestProperty("Connection", "Keep-Alive");
156 | uc.setRequestProperty("CONTENT-LENGTH", String.valueOf(bytes.length)); // 14.05.2018
157 | uc.setRequestProperty("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
158 | uc.setRequestProperty("SOAPACTION", urn);
159 | uc.setRequestProperty("Connection", "close");
160 |
161 | printout = new DataOutputStream(uc.getOutputStream());
162 | printout.write(bytes);
163 | printout.close();
164 |
165 | //Debug.info("Result of DeviceConfig getHeaderFields: " + uc.getHeaderFields());
166 |
167 | if (uc.getResponseCode() == 200) {
168 | //InputStream in = uc.getInputStream();
169 | d = new BufferedReader(new InputStreamReader(uc.getInputStream()));
170 |
171 | String str;
172 | while (null != ((str = d.readLine())))
173 | data += str + "\n";
174 | }
175 |
176 | } catch (IOException e) {
177 | Debug.error(e.toString());
178 | }finally{
179 | try{
180 | if(d!=null)
181 | d.close();
182 | }catch(IOException ioe){
183 | Debug.error("Error closing Stream");
184 | }
185 | try{
186 | if(printout!=null)
187 | printout.close();
188 | }catch(IOException ioe){
189 | Debug.error("Error closing Stream");
190 | }
191 | }
192 | //Debug.info("Result of DeviceConfig data 1: " + data);
193 | return data;
194 | }
195 |
196 | // 01.08.2015 pikachu // 27.04.2018 pikachu
197 | public static String getSIDUPNP() { // 15.08.2015
198 | String sSID = "0000000000000000";
199 | String xml =
200 | "\n" +
201 | "\n" +
203 | "\n" +
204 | "\n" +
205 | "\n" +
206 | "";
207 |
208 | String result = UPNPUtils.getSOAPDataAuth(fbe, protocol + "://" + FBEdit.getInstance().getbox_address() +
209 | URL_SERVICE_CREATEURLSID, URN_SERVICE_CREATEURLSID, xml);
210 |
211 | Pattern p = Pattern.compile("sid=([^<]*)");
212 | Matcher m = p.matcher(result);
213 | if(m.find())
214 | sSID = m.group(1);
215 | //else
216 | // sSID = "0000000000000000";
217 |
218 | //sSID = result;
219 | // Debug.info("Result of DeviceConfig CreateUrlSID: " + result);
220 | return sSID;
221 | }
222 |
223 | // 27.04.2018 pikachu
224 | public static String get2FAUPNP() { // 27.04.2018
225 | String s2FA = "";
226 | String xml =
227 | "\n" +
228 | "\n" +
230 | "\n" +
231 | "\n" +
232 | "\n" +
233 | "";
234 |
235 | String result = UPNPUtils.getSOAPDataAuth(fbe, protocol + "://" + FBEdit.getInstance().getbox_address() +
236 | URL_SERVICE_2FA, URN_SERVICE_2FA, xml);
237 |
238 | Pattern p = Pattern.compile("([^<]*)");
239 | Matcher m = p.matcher(result);
240 | if(m.find())
241 | s2FA = m.group(1);
242 | else
243 | s2FA = "0";
244 |
245 | //s2FA = result;
246 | // Debug.info("Result of X_AVM-DE_Auth GetInfo NewEnabled: " + result);
247 | return s2FA;
248 | }
249 |
250 | }
251 |
--------------------------------------------------------------------------------
/src/icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olistudent/FBEditor/2732f261e1448ad7135f5da818050fc7760eaa32/src/icon.gif
--------------------------------------------------------------------------------