Extracted JDBrowser Project (can be found under svn://svn.jdownloader.org/jdownloader/browser)

MOved Some utilities to appwork utils. next stable update needs new appwork utils library

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@13375 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
coalado 2011-01-18 10:13:44 +00:00
parent e5d6a092ae
commit b9e3afb778
779 changed files with 2730 additions and 8991 deletions

View File

@ -25,7 +25,6 @@
</classpathentry>
<classpathentry kind="lib" path="ressourcen/libs/clink170.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/mail.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/ui.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/debug-1.0.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/jcip-annotations-1.0.jar"/>
<classpathentry kind="lib" path="ressourcen/libs/Filters.jar" sourcepath="ressourcen/code-ressourcen/Filter_src.zip"/>
@ -91,5 +90,6 @@
<classpathentry kind="lib" path="ressourcen/libs/jetty-util-7.1.6.v20100715.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/jpathwatch-0-93-rc1.jar"/>
<classpathentry kind="lib" path="ressourcen/libs_ext/AppleJavaExtensions.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/JDBrowser"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,58 +1,57 @@
#Sun Oct 31 08:20:14 CET 2010
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_AppWork Javaformat
formatter_settings_version=11
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=false
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=false
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
#Tue Jan 18 10:33:08 CET 2011
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_settings_version=11
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=false
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=false
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

Binary file not shown.

View File

@ -47,6 +47,7 @@ import jd.gui.swing.jdgui.events.EDTEventQueue;
import jd.gui.swing.laf.LookAndFeelController;
import jd.http.Browser;
import jd.http.HTTPProxy;
import jd.http.ext.security.JSPermissionRestricter;
import jd.nutils.ClassFinder;
import jd.nutils.OSDetector;
import jd.nutils.encoding.Encoding;
@ -73,12 +74,14 @@ import org.lobobrowser.util.OS;
*/
public class JDInit {
static {
try {
JSPermissionRestricter.init();
} catch (final Throwable e) {
e.printStackTrace();
}
/**
* TODO: Change this String to test the changes from plugins with public
* static methods instead of annotation, e.g. CMS or Wordpress
*/
private static final String PLUGIN_DUMP = "";
}
private static final boolean TEST_INSTALLER = false;

View File

@ -23,13 +23,13 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import jd.parser.Regex;
import org.appwork.utils.Regex;
public class ObjectConverter {
protected Exception exception;
private String pre;
private String post;
private String pre;
private String post;
public String toString(final Object obj) throws Exception {
final ByteArrayOutputStream ba = new ByteArrayOutputStream();

View File

@ -60,9 +60,9 @@ import jd.http.Browser;
import jd.nutils.Executer;
import jd.nutils.JDHash;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

View File

@ -28,9 +28,10 @@ import jd.captcha.pixelgrid.Letter;
import jd.captcha.utils.Utilities;
import jd.controlling.JDLogger;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
/**
* Diese Klasse parsed das JAC Script
*

View File

@ -21,8 +21,8 @@ import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import javax.imageio.ImageIO;

View File

@ -35,10 +35,11 @@ import jd.gui.swing.components.JDLabelContainer;
import jd.nutils.JDFlags;
import jd.nutils.JDImage;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
public class EasyMethodFile implements JDLabelContainer, Serializable {
/**
* erstellt eine Liste aller vorhandener Methoden

View File

@ -20,8 +20,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.Vector;
import java.util.logging.Logger;
import jd.captcha.LetterComperator;

View File

@ -1,6 +1,7 @@
package jd.captcha.specials;
import java.awt.Color;
import jd.captcha.pixelgrid.Captcha;
import jd.captcha.pixelgrid.Letter;
import jd.captcha.pixelgrid.PixelGrid;

View File

@ -17,6 +17,7 @@
package jd.captcha.specials;
import java.awt.image.BufferedImage;
import jd.captcha.JAntiCaptcha;
import jd.captcha.pixelgrid.Captcha;
import jd.captcha.pixelgrid.Letter;

View File

@ -18,6 +18,7 @@ package jd.captcha.specials;
import java.util.ArrayList;
import java.util.Collections;
import jd.captcha.pixelgrid.Captcha;
import jd.captcha.pixelgrid.Letter;
import jd.captcha.pixelgrid.PixelGrid;

View File

@ -22,8 +22,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.Vector;
import jd.captcha.JAntiCaptcha;
import jd.captcha.LevenShteinLetterComperator;

View File

@ -31,13 +31,13 @@ import jd.gui.swing.components.Balloon;
import jd.nutils.encoding.Base64;
import jd.nutils.encoding.Encoding;
import jd.nutils.nativeintegration.LocalBrowser;
import jd.parser.Regex;
import jd.parser.html.HTMLParser;
import jd.plugins.DownloadLink;
import jd.utils.JDHexUtils;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Scriptable;

View File

@ -32,9 +32,10 @@ import jd.config.Configuration;
import jd.event.ControlEvent;
import jd.event.ControlListener;
import jd.nutils.OSDetector;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
/**
* Diese Klasse ist dafür da, zeitverzögert die Zwischenablage zu untersuchen
*

View File

@ -33,7 +33,6 @@ import jd.nutils.encoding.Encoding;
import jd.nutils.encoding.HTMLEntities;
import jd.nutils.jobber.JDRunnable;
import jd.nutils.jobber.Jobber;
import jd.parser.Regex;
import jd.parser.html.HTMLParser;
import jd.plugins.CryptedLink;
import jd.plugins.DownloadLink;
@ -43,6 +42,8 @@ import jd.utils.JDTheme;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* Diese Klasse läuft in einem Thread und verteilt den Inhalt der Zwischenablage
* an (unter Umständen auch mehrere) Plugins Die gefundenen Treffer werden

View File

@ -25,7 +25,8 @@ import javax.swing.Timer;
import jd.config.SubConfiguration;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import org.appwork.utils.Regex;
public class HTACCESSController implements ActionListener, ListController {
private transient static SubConfiguration CONFIG = null;

View File

@ -33,7 +33,6 @@ import jd.gui.UserIO;
import jd.http.Browser;
import jd.nutils.JDFlags;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.LinkStatus;
@ -42,6 +41,7 @@ import jd.plugins.PluginsC;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
import org.appwork.utils.event.Eventsender;
/**

View File

@ -25,8 +25,6 @@ import java.util.Iterator;
import javax.swing.Timer;
import org.appwork.utils.event.Eventsender;
import jd.http.Browser;
import jd.nutils.jobber.JDRunnable;
import jd.nutils.jobber.Jobber;
@ -34,6 +32,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.PluginForHost;
import jd.utils.locale.JDL;
import org.appwork.utils.event.Eventsender;
class LinkCheckBroadcaster extends Eventsender<LinkCheckListener, LinkCheckEvent> {
// @Override

View File

@ -26,7 +26,6 @@ import java.util.regex.Pattern;
import jd.config.ConfigPropertyListener;
import jd.config.Property;
import jd.config.SubConfiguration;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
@ -35,6 +34,7 @@ import jd.plugins.LinkGrabberFilePackageEvent;
import jd.plugins.LinkGrabberFilePackageListener;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
import org.appwork.utils.event.Eventsender;
class LinkGrabberControllerBroadcaster extends Eventsender<LinkGrabberControllerListener, LinkGrabberControllerEvent> {

View File

@ -19,9 +19,10 @@ package jd.controlling;
import java.util.regex.Pattern;
import jd.config.SubConfiguration;
import jd.parser.Regex;
import jd.plugins.hoster.DirectHTTP;
import org.appwork.utils.Regex;
public class LinkGrabberPackager {
public static final Pattern pat0 = Pattern.compile("(.*)(\\.|_|-)pa?r?t?\\.?[0-9]+.(rar|exe)$", Pattern.CASE_INSENSITIVE);
public static final Pattern pat1 = Pattern.compile("(.*)(\\.|_|-)part\\.?[0]*[1].(rar|exe)$", Pattern.CASE_INSENSITIVE);

View File

@ -26,7 +26,8 @@ import java.util.Set;
import javax.swing.Timer;
import jd.config.SubConfiguration;
import jd.parser.Regex;
import org.appwork.utils.Regex;
public class PasswordListController implements ActionListener, ListController {
private transient static SubConfiguration CONFIG = null;

View File

@ -33,12 +33,11 @@ import jd.gui.swing.SwingGui;
import jd.gui.swing.components.Balloon;
import jd.gui.swing.dialog.AgbDialog;
import jd.http.Browser;
import jd.http.Browser.BrowserException;
import jd.http.BrowserException;
import jd.http.BrowserSettings;
import jd.http.HTTPProxy;
import jd.nutils.Formatter;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.plugins.Account;
import jd.plugins.DownloadLink;
import jd.plugins.LinkStatus;
@ -49,6 +48,8 @@ import jd.utils.JDTheme;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* In dieser Klasse wird der Download parallel zum Hauptthread gestartet
*

View File

@ -35,9 +35,10 @@ import jd.nutils.OSDetector;
import jd.nutils.Threader;
import jd.nutils.Threader.WorkerListener;
import jd.nutils.jobber.JDRunnable;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
public class RouterUtils {
private static class WebServerChecker implements JDRunnable {

View File

@ -47,7 +47,6 @@ import jd.nutils.Formatter;
import jd.nutils.JDHash;
import jd.nutils.encoding.Encoding;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import net.miginfocom.swing.MigLayout;
@ -55,6 +54,7 @@ import net.miginfocom.swing.MigLayout;
import org.appwork.storage.StorageEvent;
import org.appwork.storage.StorageKeyAddedEvent;
import org.appwork.storage.StorageValueChangeEvent;
import org.appwork.utils.Regex;
import org.appwork.utils.event.DefaultEventListener;
import org.appwork.utils.logging.Log;
import org.appwork.utils.swing.EDTRunner;

View File

@ -39,12 +39,12 @@ import jd.controlling.reconnect.plugins.liveheader.LiveHeaderReconnect;
import jd.gui.UserIO;
import jd.gui.swing.components.linkbutton.JLink;
import jd.nutils.JDFlags;
import jd.parser.Regex;
import jd.utils.JDTheme;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import net.miginfocom.swing.MigLayout;
import org.appwork.utils.Regex;
import org.appwork.utils.swing.dialog.AbstractDialog;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;

View File

@ -22,7 +22,8 @@ import java.util.Vector;
import jd.config.SubConfiguration;
import jd.controlling.JDLogger;
import jd.parser.Regex;
import org.appwork.utils.Regex;
public class ReconnectRecorder {

View File

@ -21,18 +21,19 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.Vector;
import java.util.regex.Pattern;
import jd.config.Configuration;
import jd.config.SubConfiguration;
import jd.controlling.JDLogger;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.utils.JDHexUtils;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
public final class Utils {
/**
* Don't let anyone instantiate this class.

View File

@ -29,9 +29,10 @@ import javax.swing.KeyStroke;
import jd.config.Property;
import jd.controlling.JDLogger;
import jd.gui.swing.ShortCuts;
import jd.parser.Regex;
import jd.utils.JDTheme;
import org.appwork.utils.Regex;
/**
* This abstract class is the parent class for all actions in JDownloader
*

View File

@ -31,9 +31,6 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.table.TableCellRenderer;
import org.appwork.utils.event.DefaultEvent;
import org.appwork.utils.event.Eventsender;
import jd.config.SubConfiguration;
import jd.controlling.JDLogger;
import jd.gui.swing.components.JDUnderlinedText;
@ -41,7 +38,10 @@ import jd.gui.swing.jdgui.JDGuiConstants;
import jd.gui.swing.jdgui.interfaces.JDMouseAdapter;
import jd.nutils.Executer;
import jd.nutils.nativeintegration.LocalBrowser;
import jd.parser.Regex;
import org.appwork.utils.Regex;
import org.appwork.utils.event.DefaultEvent;
import org.appwork.utils.event.Eventsender;
class JLinkButtonRenderer implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

View File

@ -36,12 +36,13 @@ import javax.swing.TransferHandler;
import jd.controlling.DownloadController;
import jd.controlling.JDController;
import jd.gui.swing.SwingGui;
import jd.parser.Regex;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.utils.JDTheme;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
public class TableTransferHandler extends TransferHandler {
private static final long serialVersionUID = 2560352681437669412L;
private static final int DRAG_LINKS = 1;

View File

@ -37,12 +37,13 @@ import jd.controlling.DownloadController;
import jd.controlling.JDController;
import jd.controlling.LinkGrabberController;
import jd.gui.swing.SwingGui;
import jd.parser.Regex;
import jd.plugins.DownloadLink;
import jd.plugins.LinkGrabberFilePackage;
import jd.utils.JDTheme;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
public class LinkGrabberTableTransferHandler extends TransferHandler {
private static final long serialVersionUID = 2560352681437669412L;
private static final int DRAG_LINKS = 1;

View File

@ -18,10 +18,10 @@ package jd.gui.swing.jdgui.views.settings.panels.downloadandnetwork;
import jd.config.ConfigContainer;
import jd.config.ConfigEntry;
import jd.config.ConfigEntry.PropertyType;
import jd.config.ConfigGroup;
import jd.config.Configuration;
import jd.config.SubConfiguration;
import jd.config.ConfigEntry.PropertyType;
import jd.gui.swing.jdgui.views.settings.ConfigPanel;
import jd.utils.locale.JDL;

View File

@ -22,9 +22,9 @@ import java.util.ArrayList;
import jd.config.ConfigContainer;
import jd.config.ConfigEntry;
import jd.config.ConfigEntry.PropertyType;
import jd.config.ConfigGroup;
import jd.config.SubConfiguration;
import jd.config.ConfigEntry.PropertyType;
import jd.gui.UserIO;
import jd.gui.swing.jdgui.GUIUtils;
import jd.gui.swing.jdgui.JDGuiConstants;

View File

@ -25,8 +25,8 @@ import javax.swing.Timer;
import jd.config.ConfigContainer;
import jd.config.ConfigEntry;
import jd.config.ConfigGroup;
import jd.config.ConfigEntry.PropertyType;
import jd.config.ConfigGroup;
import jd.controlling.AccountController;
import jd.controlling.AccountControllerEvent;
import jd.controlling.AccountControllerListener;

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
package jd.http;
import java.util.logging.Logger;
public interface BrowserSettings {
public HTTPProxy getCurrentProxy();
public void setCurrentProxy(HTTPProxy proxy);
public void setVerbose(boolean b);
public boolean isVerbose();
public void setDebug(boolean b);
public boolean isDebug();
public void setLogger(Logger logger);
public Logger getLogger();
}

View File

@ -1,226 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import jd.controlling.JDLogger;
public class Cookie {
private static final String[] dateformats = new String[] { "EEE, dd-MMM-yy HH:mm:ss z", "EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd MMM yyyy HH:mm:ss z", "EEE MMM dd HH:mm:ss z yyyy", "EEE, dd-MMM-yyyy HH:mm:ss z", "EEEE, dd-MMM-yy HH:mm:ss z" };
private String path;
private String host;
private String value;
private String key;
private String domain;
private long hostTime = -1;
private long creationTime = System.currentTimeMillis();
private long expireTime = -1;
public Cookie(final String host, final String key, final String value) {
this.host = host;
this.key = key;
this.value = value;
}
public Cookie() {
host = "";
key = "";
value = "";
}
public long getCreationTime() {
return creationTime;
}
public void setCreationTime(final long time) {
creationTime = time;
}
public void setHost(final String host) {
this.host = host;
}
public void setPath(final String path) {
this.path = path;
}
public void setExpires(final String expires) {
if (expires == null) {
this.expireTime = -1;
// System.out.println("setExpire: Cookie: no expireDate found! " +
// this.host + " " + this.key);
return;
}
Date expireDate = null;
for (String format : dateformats) {
try {
final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.UK);
sdf.setLenient(false);
expireDate = sdf.parse(expires);
break;
} catch (Exception e2) {
}
}
if (expireDate != null) {
this.expireTime = expireDate.getTime();
return;
}
this.expireTime = -1;
JDLogger.getLogger().severe("Cookie: no Format for " + expires + " found!");
return;
}
public void setValue(final String value) {
this.value = value;
}
public void setKey(final String key) {
this.key = key;
}
public void setDomain(final String domain) {
this.domain = domain;
}
public boolean isExpired() {
if (this.expireTime == -1) {
// System.out.println("isexpired: no expireDate found! " + this.host
// + " " + this.key);
return false;
}
if (this.hostTime == -1) {
JDLogger.getLogger().severe("Cookie: no HostTime found! ExpireStatus cannot be checked " + this.host + " " + this.key);
return false;
} else {
final long check = (System.currentTimeMillis() - this.creationTime) + this.hostTime;
// System.out.println(this.host + " " + this.key + " " +
// this.creationTime + " " + this.hostTime + " " + this.expireTime +
// " " + check);
// if (check > this.expireTime) {
// // System.out.println("Expired: " + this.host + " " + this.key);
// return true;
// } else
// return false;
return check > this.expireTime;
}
}
public long getHostTime() {
return this.hostTime;
}
public void setHostTime(final long time) {
hostTime = time;
}
public long getExpireDate() {
return this.expireTime;
}
public void setExpireDate(final long time) {
expireTime = time;
}
public void setHostTime(final String date) {
if (date == null) {
this.hostTime = -1;
// System.out.println("Cookie: no HostTime found! " + this.host +
// " " + this.key);
return;
}
Date responseDate = null;
for (String format : dateformats) {
try {
final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.UK);
sdf.setLenient(false);
responseDate = sdf.parse(date);
break;
} catch (Exception e2) {
}
}
if (responseDate != null) {
this.hostTime = responseDate.getTime();
return;
}
this.hostTime = -1;
JDLogger.getLogger().severe("Cookie: no Format for " + date + " found!");
return;
}
public String getPath() {
return path;
}
public String getHost() {
return host;
}
public String getValue() {
return value;
}
public String getKey() {
return key;
}
public String getDomain() {
return domain;
}
public String toString() {
return key + "=" + value + " @" + host;
}
public void update(final Cookie cookie2) {
this.setCreationTime(cookie2.creationTime);
this.setExpireDate(cookie2.expireTime);
this.setValue(cookie2.value);
// this.setHostTime(cookie2.getCreationTime());
this.setHostTime(cookie2.creationTime); // ???
}
// /* compares host and key */
// public boolean equals(final Cookie cookie2) {
// if (cookie2 == this) return true;
// if (!cookie2.getHost().equalsIgnoreCase(this.getHost())) return false;
// if (!cookie2.getKey().equalsIgnoreCase(this.getKey())) return false;
// return true;
// }
/* compares host and key */
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Cookie other = (Cookie) obj;
if (host == null) {
if (other.host != null) return false;
} else if (!host.equalsIgnoreCase(other.host)) return false;
if (key == null) {
if (other.key != null) return false;
} else if (!key.equalsIgnoreCase(other.key)) return false;
return true;
}
}

View File

@ -1,177 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import jd.parser.Regex;
public class Cookies {
private final LinkedList<Cookie> cookies = new LinkedList<Cookie>();
public Cookies() {
}
public Cookies(final Cookies cookies) {
add(cookies);
}
public void add(final Cookies newcookies) {
synchronized (cookies) {
for (final Cookie cookie : newcookies.getCookies()) {
add(cookie);
}
}
}
public void add(final Cookie cookie) {
synchronized (cookies) {
for (Cookie cookie2 : cookies) {
if (cookie2.equals(cookie)) {
cookie2.update(cookie);
return;
}
}
cookies.add(cookie);
}
}
public void remove(final Cookie cookie) {
synchronized (cookies) {
if (!cookies.remove(cookie)) {
Cookie del = null;
for (final Cookie cookie2 : cookies) {
if (cookie2.equals(cookie)) {
del = cookie2;
break;
}
}
if (del != null) {
cookies.remove(del);
}
}
}
}
public void clear() {
synchronized (cookies) {
cookies.clear();
}
}
public Cookie get(final String key) {
if (key == null) { return null; }
synchronized (cookies) {
for (Cookie cookie : cookies) {
if (cookie.getKey().equalsIgnoreCase(key)) { return cookie; }
}
return null;
}
}
public LinkedList<Cookie> getCookies() {
return cookies;
}
public boolean isEmpty() {
return cookies.isEmpty();
}
public static Cookies parseCookies(final String cookieString, final String host, final String serverTime) {
final Cookies cookies = new Cookies();
final String header = cookieString;
String path = null;
String expires = null;
String domain = null;
final LinkedHashMap<String, String> tmp = new LinkedHashMap<String, String>();
/* Cookie individual elements */
final StringTokenizer st = new StringTokenizer(header, ";");
while (true) {
String key = null;
String value = null;
String cookieelement = null;
if (st.hasMoreTokens()) {
cookieelement = st.nextToken().trim();
} else {
break;
}
/* Key and Value */
final String st2[] = new Regex(cookieelement, "(.*?)=(.*)").getRow(0);
if (st2 == null || st2.length == 0) {
key = null;
} else if (st2.length == 1) {
key = st2[0].trim();
} else if (st2.length == 2) {
key = st2[0].trim();
value = st2[1].trim();
}
if (key != null) {
if (key.equalsIgnoreCase("path")) {
path = value;
} else if (key.equalsIgnoreCase("expires")) {
expires = value;
} else if (key.equalsIgnoreCase("domain")) {
domain = value;
} else {
tmp.put(key, value);
}
} else {
break;
}
}
for (final Iterator<Entry<String, String>> it = tmp.entrySet().iterator(); it.hasNext();) {
final Entry<String, String> next = it.next();
/*
* no cookies are cookies without a value
*/
if (next.getValue() != null) {
final Cookie cookie = new Cookie();
cookies.add(cookie);
cookie.setHost(host);
cookie.setPath(path);
cookie.setDomain(domain);
cookie.setExpires(expires);
cookie.setValue(next.getValue());
cookie.setKey(next.getKey());
cookie.setHostTime(serverTime);
}
}
return cookies;
}
@Override
public String toString() {
final StringBuilder ret = new StringBuilder();
for (final Cookie el : cookies) {
ret.append(el.toString() + "\r\n");
}
return ret.toString();
}
}

View File

@ -1,399 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import jd.http.requests.PostFormDataRequest;
import jd.http.requests.PostRequest;
import jd.parser.Regex;
import sun.net.www.MessageHeader;
import sun.net.www.http.ChunkedInputStream;
public class HTTPConnection implements URLConnectionAdapter {
protected LinkedHashMap<String, String> requestProperties = null;
protected long[] ranges;
protected Request request;
protected String customcharset = null;
protected Socket httpSocket = null;
protected URL httpURL = null;
protected HTTPProxy proxy = null;
protected String httpPath = null;
protected METHOD httpMethod = METHOD.GET;
protected LowerCaseHashMap<List<String>> headers = null;
protected int httpResponseCode = -1;
protected String httpResponseMessage = "";
protected int readTimeout = 30000;
protected int connectTimeout = 30000;
protected long requestTime = -1;
protected InputStream inputStream = null;
protected boolean inputStreamConnected = false;
protected String httpHeader = null;
protected byte[] preReadBytes = null;
protected boolean outputClosed = false;
public boolean isConnected() {
if (httpSocket != null && httpSocket.isConnected()) return true;
return false;
}
public HTTPConnection(URL url) {
this(url, null);
}
public HTTPConnection(URL url, HTTPProxy p) {
httpURL = url;
proxy = p;
requestProperties = new LinkedHashMap<String, String>();
headers = new LowerCaseHashMap<List<String>>();
}
public void connect() throws IOException {
if (isConnected()) return;/* oder fehler */
if (httpURL.getProtocol().startsWith("https")) {
SocketFactory socketFactory = SSLSocketFactory.getDefault();
httpSocket = socketFactory.createSocket();
} else {
httpSocket = createSocket();
}
httpSocket.setSoTimeout(readTimeout);
httpResponseCode = -1;
/* host auflösen nur wenn kein proxy, ansonsten über proxy */
InetAddress host = null;
try {
host = Inet4Address.getByName(httpURL.getHost());
} catch (UnknownHostException e) {
System.out.println("Unknown Host:" + httpURL);
throw e;
}
int port = httpURL.getPort();
if (port == -1) port = httpURL.getDefaultPort();
long startTime = System.currentTimeMillis();
if (proxy != null && !proxy.getType().equals(HTTPProxy.TYPE.DIRECT)) {
throw new RuntimeException("Invalid Direct Proxy");
} else {
httpSocket.connect(new InetSocketAddress(host, port), connectTimeout);
}
requestTime = System.currentTimeMillis() - startTime;
httpPath = new Regex(httpURL.toString(), "https?://.*?(/.+)").getMatch(0);
if (httpPath == null) httpPath = "/";
/* now send Request */
StringBuilder sb = new StringBuilder();
sb.append(httpMethod.name()).append(' ').append(httpPath).append(" HTTP/1.1\r\n");
for (String key : this.requestProperties.keySet()) {
if (requestProperties.get(key) == null) continue;
sb.append(key).append(": ").append(requestProperties.get(key)).append("\r\n");
}
sb.append("\r\n");
httpSocket.getOutputStream().write(sb.toString().getBytes("UTF-8"));
httpSocket.getOutputStream().flush();
if (httpMethod != METHOD.POST) {
outputClosed = true;
connectInputStream();
}
}
protected synchronized void connectInputStream() throws IOException {
if (inputStreamConnected) return;
inputStreamConnected = true;
/* first read http header */
ByteBuffer header = HTTPConnectionUtils.readheader(httpSocket.getInputStream(), true);
byte[] bytes = new byte[header.limit()];
header.get(bytes);
httpHeader = new String(bytes, "ISO-8859-1").trim();
/* parse response code/message */
if (httpHeader.startsWith("HTTP")) {
String code = new Regex(httpHeader, "HTTP.*? (\\d+)").getMatch(0);
if (code != null) httpResponseCode = Integer.parseInt(code);
httpResponseMessage = new Regex(httpHeader, "HTTP.*? \\d+ (.+)").getMatch(0);
if (httpResponseMessage == null) httpResponseMessage = "";
} else {
preReadBytes = bytes;
httpHeader = "unknown HTTP response";
httpResponseCode = 200;
httpResponseMessage = "unknown HTTP response";
inputStream = httpSocket.getInputStream();
return;
}
/* read rest of http headers */
header = HTTPConnectionUtils.readheader(httpSocket.getInputStream(), false);
bytes = new byte[header.limit()];
header.get(bytes);
String temp = new String(bytes, "UTF-8");
/* split header into single strings, use RN or N(buggy fucking non rfc) */
String[] headerStrings = temp.split("(\r\n)|(\n)");
temp = null;
for (int i = 0; i < headerStrings.length; i++) {
String line = headerStrings[i];
String key = null;
String value = null;
if (line.indexOf(": ") > 0) {
key = line.substring(0, line.indexOf(": "));
value = line.substring(line.indexOf(": ") + 2);
} else {
key = null;
value = line;
}
List<String> list = headers.get(key);
if (list == null) {
list = new ArrayList<String>();
headers.put(key, list);
}
list.add(value);
}
headerStrings = null;
List<String> chunked = headers.get("Transfer-Encoding");
if (chunked != null && chunked.size() > 0 && "chunked".equalsIgnoreCase(chunked.get(0))) {
/* TODO: write own chunkedinputstream */
inputStream = new ChunkedInputStream(httpSocket.getInputStream(), new MyHttpClient(), new MessageHeader());
} else {
inputStream = httpSocket.getInputStream();
}
}
public long getLongContentLength() {
String length = getHeaderField("Content-Length");
if (length == null) { return -1; }
return Long.parseLong(length);
}
public int getContentLength() {
return (int) getLongContentLength();
}
public String getContentType() {
String type = getHeaderField("Content-Type");
if (type == null) return "unknown";
return type;
}
public InputStream getInputStream() throws IOException {
connect();
connectInputStream();
if ((getResponseCode() >= 200 && getResponseCode() <= 400) || getResponseCode() == 404) {
return inputStream;
} else {
throw new IOException(getResponseCode() + " " + getResponseMessage());
}
}
public Map<String, String> getRequestProperties() {
return requestProperties;
}
public void setRequestProperty(String key, String value) {
requestProperties.put(key, value);
}
public boolean isOK() {
if (getResponseCode() > -2 && getResponseCode() < 400) return true;
return false;
}
public long[] getRange() {
String range;
if (ranges != null) return ranges;
if ((range = this.getHeaderField("Content-Range")) == null) return null;
// bytes 174239-735270911/735270912
String[] ranges = new Regex(range, ".*?(\\d+).*?-.*?(\\d+).*?/.*?(\\d+)").getRow(0);
if (ranges == null) {
System.err.print(this + "");
return null;
}
this.ranges = new long[] { Long.parseLong(ranges[0]), Long.parseLong(ranges[1]), Long.parseLong(ranges[2]) };
return this.ranges;
}
public boolean isContentDisposition() {
return this.getHeaderField("Content-Disposition") != null;
}
public void disconnect() {
if (isConnected()) {
try {
httpSocket.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("-->").append(this.getURL()).append("\r\n");
sb.append("----------------Request------------------\r\n");
sb.append(httpMethod.toString()).append(' ').append(getURL().getPath()).append((getURL().getQuery() != null ? "?" + getURL().getQuery() : "")).append(" HTTP/1.1\r\n");
for (String key : this.getRequestProperties().keySet()) {
String v = this.getRequestProperties().get(key);
if (v == null) continue;
sb.append(key);
sb.append(new char[] { ':', ' ' });
sb.append(v);
sb.append(new char[] { '\r', '\n' });
}
sb.append(new char[] { '\r', '\n' });
if (this.getRequest() != null) {
if (getRequest() instanceof PostRequest) {
if (((PostRequest) getRequest()).getPostDataString() != null) sb.append(((PostRequest) getRequest()).getPostDataString());
sb.append(new char[] { '\r', '\n' });
} else if (getRequest() instanceof PostFormDataRequest) {
if (((PostFormDataRequest) getRequest()).getPostDataString() != null) sb.append(((PostFormDataRequest) getRequest()).getPostDataString());
sb.append(new char[] { '\r', '\n' });
}
}
sb.append("----------------Response------------------\r\n");
sb.append(httpHeader).append("\r\n");
for (Iterator<Entry<String, List<String>>> it = getHeaderFields().entrySet().iterator(); it.hasNext();) {
Entry<String, List<String>> next = it.next();
// Achtung cookie reihenfolge ist wichtig!!!
for (int i = next.getValue().size() - 1; i >= 0; i--) {
if (next.getKey() == null) {
sb.append(next.getValue().get(i));
sb.append(new char[] { '\r', '\n' });
} else {
sb.append(next.getKey());
sb.append(new char[] { ':', ' ' });
sb.append(next.getValue().get(i));
sb.append(new char[] { '\r', '\n' });
}
}
}
sb.append(new char[] { '\r', '\n' });
return sb.toString();
}
public void setRequest(Request request) {
this.request = request;
}
public Request getRequest() {
return request;
}
public String getCharset() {
int i;
if (customcharset != null) return customcharset;
return (getContentType() != null && (i = getContentType().toLowerCase().indexOf("charset=")) > 0) ? getContentType().substring(i + 8).trim() : null;
}
public void setCharset(String Charset) {
this.customcharset = Charset;
}
public String getHeaderField(String string) {
List<String> ret = headers.get(string);
if (ret == null || ret.size() == 0) return null;
return ret.get(0);
}
public OutputStream getOutputStream() throws IOException {
connect();
if (outputClosed) throw new IOException("OutputStream no longer available");
return httpSocket.getOutputStream();
}
public String getRequestProperty(String string) {
return requestProperties.get(string);
}
public int getResponseCode() {
return this.httpResponseCode;
}
public String getResponseMessage() {
return this.httpResponseMessage;
}
public URL getURL() {
return httpURL;
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}
public void setRequestMethod(METHOD method) {
this.httpMethod = method;
}
public Map<String, List<String>> getHeaderFields() {
return headers;
}
public long getRequestTime() {
return requestTime;
}
public METHOD getRequestMethod() {
return this.httpMethod;
}
public byte[] preReadBytes() {
byte[] ret = preReadBytes;
preReadBytes = null;
return ret;
}
public void postDataSend() throws IOException {
if (!this.isConnected()) return;
/* disable outputStream now */
outputClosed = true;
connectInputStream();
}
public Socket createSocket() throws IOException {
return new Socket();
}
}

View File

@ -1,14 +0,0 @@
package jd.http;
import java.net.URL;
public class HTTPConnectionFactory {
static URLConnectionAdapter createHTTPConnection(URL url, HTTPProxy proxy) {
if (proxy == null) { return new HTTPConnection(url); }
if (proxy.getType().equals(HTTPProxy.TYPE.DIRECT)) { return new HTTPConnection(url, proxy); }
if (proxy.getType().equals(HTTPProxy.TYPE.SOCKS5)) { return new Socks5HTTPConnection(url, proxy); }
if (proxy.getType().equals(HTTPProxy.TYPE.HTTP)) { return new HTTPProxyHTTPConnection(url, proxy); }
throw new RuntimeException("unsupported proxy type: " + proxy.getType().name());
}
}

View File

@ -1,76 +0,0 @@
package jd.http;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
public class HTTPConnectionUtils {
private static byte R = (byte) 13;
private static byte N = (byte) 10;
public static InputStream newInputStream(final ByteBuffer buf) {
return new InputStream() {
public synchronized int read() throws IOException {
if (!buf.hasRemaining()) { return -1; }
return buf.get();
}
public synchronized int read(final byte[] bytes, final int off, int len) throws IOException {
// Read only what's left
if (!buf.hasRemaining()) { return -1; }
len = Math.min(len, buf.remaining());
buf.get(bytes, off, len);
return len;
}
};
}
public static ByteBuffer readheader(final InputStream in, boolean onlyHTTPHeader) throws IOException {
ByteBuffer bigbuffer = ByteBuffer.allocateDirect(4096);
final byte[] minibuffer = new byte[1];
int position;
int c;
boolean complete = false;
while ((c = in.read(minibuffer)) >= 0) {
if (bigbuffer.remaining() < 1) {
final ByteBuffer newbuffer = ByteBuffer.allocateDirect((bigbuffer.capacity() * 2));
bigbuffer.flip();
newbuffer.put(bigbuffer);
bigbuffer = newbuffer;
}
if (c > 0) bigbuffer.put(minibuffer);
if (onlyHTTPHeader) {
if (bigbuffer.position() >= 1) {
/*
* \n only line termination, for fucking buggy non rfc
* servers
*/
position = bigbuffer.position();
if (bigbuffer.get(position - 1) == N) {
break;
}
}
if (bigbuffer.position() >= 2) {
/* \r\n, correct line termination */
position = bigbuffer.position();
if (bigbuffer.get(position - 2) == R && bigbuffer.get(position - 1) == N) {
break;
}
}
} else {
if (bigbuffer.position() >= 4) {
/* RNRN for header<->content divider */
position = bigbuffer.position();
complete = bigbuffer.get(position - 4) == R;
complete &= bigbuffer.get(position - 3) == N;
complete &= bigbuffer.get(position - 2) == R;
complete &= bigbuffer.get(position - 1) == N;
if (complete) break;
}
}
}
bigbuffer.flip();
return bigbuffer;
}
}

View File

@ -1,119 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import jd.controlling.JDLogger;
import jd.parser.Regex;
public class HTTPProxy {
public static enum TYPE {
NONE, DIRECT, SOCKS5, HTTP
}
public static enum STATUS {
OK, OFFLINE, INVALIDAUTH
}
public static final HTTPProxy NONE = new HTTPProxy(TYPE.NONE);
private String user = null;
private String pass = null;
private int port = 80;
private String host = null;
private TYPE type = TYPE.DIRECT;
private STATUS status = STATUS.OK;
/**
* @return the status
*/
public STATUS getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(STATUS status) {
this.status = status;
}
public String getUser() {
return user;
}
public void setUser(final String user) {
this.user = user;
}
public String getPass() {
return pass;
}
public void setPass(final String pass) {
this.pass = pass;
}
public int getPort() {
return port;
}
public HTTPProxy(TYPE type, final String host, final int port) {
this.port = port;
this.type = type;
this.host = getInfo(host, "" + port)[0];
}
private HTTPProxy(TYPE type) {
this.type = type;
}
private static String[] getInfo(final String host, final String port) {
final String[] info = new String[2];
if (host == null) return info;
final String tmphost = host.replaceFirst("http://", "").replaceFirst("https://", "");
String tmpport = new Regex(host, ".*?:(\\d+)").getMatch(0);
if (tmpport != null) {
info[1] = "" + tmpport;
} else {
if (port != null) {
tmpport = new Regex(port, "(\\d+)").getMatch(0);
}
if (tmpport != null) {
info[1] = "" + tmpport;
} else {
JDLogger.getLogger().severe("No proxyport defined, using default 8080");
info[1] = "8080";
}
}
info[0] = new Regex(tmphost, "(.*?)(:|/|$)").getMatch(0);
return info;
}
public TYPE getType() {
return type;
}
public String getHost() {
return host;
}
public String toString() {
return "HTTPProxy: " + type.name() + " " + host;
}
}

View File

@ -1,64 +0,0 @@
package jd.http;
import java.io.IOException;
import java.io.InputStream;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URL;
import jd.nutils.encoding.Encoding;
public class HTTPProxyHTTPConnection extends HTTPConnection {
public HTTPProxyHTTPConnection(URL url, HTTPProxy p) {
super(url, p);
}
/* TODO: proxy to ssl and ssl proxy */
@Override
public void connect() throws IOException {
if (proxy == null || !proxy.getType().equals(HTTPProxy.TYPE.HTTP)) { throw new IOException("HTTPProxyHTTPConnection: invalid HTTP Proxy!"); }
if ((proxy.getPass() != null && proxy.getPass().length() > 0) || (proxy.getUser() != null && proxy.getUser().length() > 0)) {
/* add proxy auth */
String user = proxy.getUser() == null ? "" : proxy.getUser();
String pass = proxy.getPass() == null ? "" : proxy.getPass();
requestProperties.put("Proxy-Authorization", "Basic " + Encoding.Base64Encode(user + ":" + pass));
}
if (isConnected()) return;/* oder fehler */
httpSocket = createSocket();
httpSocket.setSoTimeout(readTimeout);
httpResponseCode = -1;
InetAddress host = Inet4Address.getByName(proxy.getHost());
long startTime = System.currentTimeMillis();
httpSocket.connect(new InetSocketAddress(host, proxy.getPort()), connectTimeout);
requestTime = System.currentTimeMillis() - startTime;
httpPath = httpURL.toString();
/* now send Request */
StringBuilder sb = new StringBuilder();
sb.append(httpMethod.name()).append(' ').append(httpPath).append(" HTTP/1.1\r\n");
for (String key : this.requestProperties.keySet()) {
if (requestProperties.get(key) == null) continue;
sb.append(key).append(": ").append(requestProperties.get(key)).append("\r\n");
}
sb.append("\r\n");
httpSocket.getOutputStream().write(sb.toString().getBytes("UTF-8"));
httpSocket.getOutputStream().flush();
if (httpMethod != METHOD.POST) {
outputClosed = true;
connectInputStream();
}
}
@Override
public InputStream getInputStream() throws IOException {
connect();
connectInputStream();
if ((getResponseCode() == 407)) proxy.setStatus(HTTPProxy.STATUS.INVALIDAUTH);
if ((getResponseCode() >= 200 && getResponseCode() <= 400) || getResponseCode() == 404) {
return inputStream;
} else {
throw new IOException(getResponseCode() + " " + getResponseMessage());
}
}
}

View File

@ -1,29 +0,0 @@
package jd.http;
import java.util.LinkedHashMap;
public class LowerCaseHashMap<V> extends LinkedHashMap<String, V> {
/**
*
*/
private static final long serialVersionUID = 4571590512548374247L;
public V get(Object key) {
if (key != null && key.getClass() == String.class) { return super.get(((String) key).toLowerCase()); }
return super.get(key);
}
public V put(String key, V value) {
if (key != null) {
return super.put(key.toLowerCase(), value);
} else {
return super.put(key, value);
}
}
public V remove(Object key){
if (key != null && key.getClass() == String.class) { return super.remove(((String) key).toLowerCase()); }
return super.remove(key);
}
}

View File

@ -1,15 +0,0 @@
package jd.http;
import sun.net.www.http.HttpClient;
public class MyHttpClient extends HttpClient {
@Override
public void finished() {
}
@Override
public void openServer(String server, int port) {
}
}

View File

@ -1,308 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Random;
import jd.nutils.Formatter;
public final class RandomUserAgent {
/**
* Don't let anyone instantiate this class.
*/
private RandomUserAgent() {
}
/**
* Initial browser release date. Used for invalid randomDate() calls.
*/
private static final String[] releaseDate = { "2005", "11", "11" };
/**
* Browser-Language
*/
private static ArrayList<String> langs = new ArrayList<String>();
/**
* Firefox branch revision, version and release date triplet. They MUST
* match! Release date in form of "YYYY.MM.DD[.HH]". As of Firefox version >
* 3.0 buildHour is appended. Use ".xx"
*/
private static ArrayList<String> ffVersionInfos = new ArrayList<String>();
/**
* Internet Explorer versions
*/
private static ArrayList<String> ieVersions = new ArrayList<String>();
/**
* Windows Versions. E.g. NT 5.1 is Windows XP
*/
private static String winVersions = "";
/**
* Windows: dotNet addon-strings, to make the user-agent more random
*/
private static ArrayList<String[]> winAddons = new ArrayList<String[]>();
/**
* Linux: distribution addon-strings, to make the user-agent more random
*/
private static ArrayList<String> linuxAddons = new ArrayList<String>();
/**
* Macintosh: version addon-strings, to make the user-agent more random
*/
private static ArrayList<String> macAddons = new ArrayList<String>();
/**
* Information about the system: platform, OS, architecture
*/
private static ArrayList<System> system = new ArrayList<System>();
/**
* Fill in the values (the "CONFIGURATION")
*/
static {
/* Used only in generateIE */
ieVersions.add("6.0");
ieVersions.add("7.0");
ieVersions.add("8.0");
/* Used in both generateIE and generateFF */
winVersions = "NT 5.0|NT 5.1|NT 5.2|NT 6.0|NT 6.1";
winAddons.add(new String[] { "", ".NET CLR 1.0.3705", ".NET CLR 1.1.4322" });
winAddons.add(new String[] { "", ".NET CLR 2.0.40607", ".NET CLR 2.0.50727" });
winAddons.add(new String[] { "", ".NET CLR 3.0.04506.648", ".NET CLR 3.0.4506.2152" });
winAddons.add(new String[] { "", ".NET CLR 3.5.21022", ".NET CLR 3.5.30729" });
/* Used only in generateFF */
langs.add("en");
langs.add("en-US");
langs.add("en-GB");
ffVersionInfos.add("1.8|1.5|2005.11.11");
ffVersionInfos.add("1.8.1|2.0|2006.10.10");
ffVersionInfos.add("1.9|3.0|2008.05.29.xx");
ffVersionInfos.add("1.9.0.5|3.0.5|2008.12.01.xx");
ffVersionInfos.add("1.9.0.6|3.0.6|2009.01.19.xx");
ffVersionInfos.add("1.9.0.7|3.0.7|2009.02.19.xx");
ffVersionInfos.add("1.9.0.8|3.0.8|2009.03.26.xx");
ffVersionInfos.add("1.9.0.9|3.0.9|2009.04.08.xx");
ffVersionInfos.add("1.9.0.10|3.0.10|2009.04.23.xx");
linuxAddons.add(" ");
linuxAddons.add("Ubuntu/8.04 (hardy)");
linuxAddons.add("Ubuntu/8.10 (intrepid)");
// linuxAddons.add("Ubuntu/9.04 (jaunty)");
linuxAddons.add("Fedora/3.0.6-1.fc10");
linuxAddons.add("Fedora/3.0.10-1.fc10");
linuxAddons.add("(Gentoo)");
linuxAddons.add("SUSE/3.0-1.2");
linuxAddons.add("SUSE/3.0-1.1");
linuxAddons.add("Red Hat/3.0.5-1.el5_2");
macAddons.add("");
macAddons.add("Mach-O");
macAddons.add("10.4");
macAddons.add("10.5");
macAddons.add("10.6");
system.add(new System("Windows", "Windows", winVersions, false, true));
system.add(new System("X11", "Linux", "x86|x86_64|i586|i686", false, true));
system.add(new System("Macintosh", "Mac OS X", "Intel|PPC|68K", true, true));
system.add(new System("X11", "FreeBSD", "i386|amd64|sparc64|alpha", false, true));
system.add(new System("X11", "OpenBSD", "i386|amd64|sparc64|alpha", false, true));
system.add(new System("X11", "NetBSD", "i386|amd64|sparc64|alpha", false, true));
system.add(new System("X11", "SunOS", "i86pc|sun4u", false, true));
}
/**
* The main user-agent string generator
*
* @return Random Firefox or Internet Explorer user-agent string
*/
public static String generate() {
if ((new Random().nextInt() % 2) == 0)
return generateFF();
else
return generateIE();
}
/**
* The Firefox user-agent string generator
*
* @return Random Firefox user-agent string
*/
public static String generateFF() {
final Random rand = new Random();
String platform = "";
String osAndArch = "";
String winAddon = "";
String linuxAddon = " ";
String macAddon = "";
/* Get system infos */
final int i = rand.nextInt(system.size());
do {
platform = system.get(i).platform;
final String osName = system.get(i).osName;
final String[] archs = system.get(i).archs.split("\\|");
final String arch = archs[rand.nextInt(archs.length)];
if (!system.get(i).inverseOrder)
osAndArch = osName + " " + arch;
else
osAndArch = arch + " " + osName;
} while (system.get(i).useIt == false);
/* Get optional strings */
if (system.get(i).osName.equalsIgnoreCase("Windows")) {
winAddon = dotNetString();
if (winAddon.trim().length() > 0) {
winAddon = (" (" + winAddon.trim() + ")").replace("(; ", "(");
}
} else if (system.get(i).osName.equalsIgnoreCase("Linux")) {
linuxAddon = linuxAddons.get(rand.nextInt(linuxAddons.size()));
if (linuxAddon != " ") {
linuxAddon = " " + linuxAddon.trim() + " ";
}
} else if (system.get(i).osName.equalsIgnoreCase("Mac OS X")) {
macAddon = macAddons.get(rand.nextInt(macAddons.size()));
if (macAddon != "") {
macAddon = " " + macAddon.trim();
}
}
/* Get Browser language */
final String lang = langs.get(rand.nextInt(langs.size()));
/* Get Firefox branch revision, version and release date */
final String[] tmpFFVersionInfos = ffVersionInfos.get(rand.nextInt(ffVersionInfos.size())).split("\\|");
final String ffRev = tmpFFVersionInfos[0];
final String ffVersion = tmpFFVersionInfos[1];
final String[] ffReleaseDate = tmpFFVersionInfos[2].split("\\.");
return "Mozilla/5.0 (" + platform + "; U; " + osAndArch + macAddon + "; " + lang + "; rv:" + ffRev + ") Gecko/" + randomDate(ffReleaseDate) + linuxAddon + "Firefox/" + ffVersion + winAddon;
}
/**
* The Internet Explorer user-agent string generator
*
* @return Random Internet Explorer user-agent string
*/
public static String generateIE() {
final Random rand = new Random();
final String ieVersion = ieVersions.get(rand.nextInt(ieVersions.size()));
final String winVersion = winVersions.split("\\|")[rand.nextInt(winVersions.split("\\|").length)];
String trident = "";
if (ieVersion.equalsIgnoreCase("8.0")) {
trident = "; Trident/4.0";
}
return "Mozilla/4.0 (compatible; MSIE " + ieVersion + "; Windows " + winVersion + trident + dotNetString() + ")";
}
private static String dotNetString() {
final Random rand = new Random();
String dotNet10 = "; " + winAddons.get(0)[rand.nextInt(winAddons.get(0).length)];
if (dotNet10.equalsIgnoreCase("; ")) {
dotNet10 = "";
}
String dotNet20 = "; " + winAddons.get(1)[rand.nextInt(winAddons.get(1).length)];
if (dotNet20.equalsIgnoreCase("; ")) {
dotNet20 = "";
}
String dotNet30 = "";
if (dotNet20.length() != 0) {
dotNet30 = "; " + winAddons.get(2)[rand.nextInt(winAddons.get(2).length)];
}
if (dotNet30.equalsIgnoreCase("; ")) {
dotNet30 = "";
}
String dotNet35 = "";
if (dotNet30.length() != 0) {
dotNet35 = "; " + winAddons.get(3)[rand.nextInt(winAddons.get(3).length)];
}
if (dotNet35.equalsIgnoreCase("; ")) {
dotNet35 = "";
}
return dotNet10 + dotNet20 + dotNet30 + dotNet35;
}
/**
* Generates a random date in form of "YYYYMMDD[HH]" between releaseDate and
* the current date
*
* @return random date
*/
private static String randomDate(final String[] releaseDate) {
String returnDate = RandomUserAgent.releaseDate[0] + RandomUserAgent.releaseDate[1] + RandomUserAgent.releaseDate[2];
if (releaseDate == null || releaseDate.length < 3 || releaseDate.length > 4) return returnDate;
final Calendar rCal = new GregorianCalendar(Integer.parseInt(releaseDate[0]), Integer.parseInt(releaseDate[1]) - 1, Integer.parseInt(releaseDate[2]));
final long rTime = rCal.getTimeInMillis();
final long cTime = new GregorianCalendar().getTimeInMillis();
final Random rand = new Random();
int temp = (int) ((cTime - rTime) / (60 * 1000)) + (int) (rTime / (60 * 1000));
if (temp < 0) {
temp = -temp;
}
final long randTime = rand.nextInt(temp);
rCal.setTimeInMillis(randTime * (60 * 1000));
final int year = rCal.get(Calendar.YEAR);
final String month = Formatter.fillString((rCal.get(Calendar.MONTH) + 1) + "", "0", "", 2);
final String day = Formatter.fillString(rCal.get(Calendar.DAY_OF_MONTH) + "", "0", "", 2);
String hour = "";
if (releaseDate.length == 4) {
hour = Formatter.fillString(rand.nextInt(24) + "", "0", "", 2);
}
returnDate = "" + year + month + day + hour;
return returnDate;
}
private static class System {
public String platform;
public String osName;
public String archs;
public boolean inverseOrder;
public boolean useIt;
public System(final String platform, final String osName, final String archs, final boolean inverseOrder, final boolean useIt) {
this.platform = platform;
this.osName = osName;
this.archs = archs;
this.inverseOrder = inverseOrder;
this.useIt = useIt;
}
}
}

View File

@ -1,550 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.CharacterCodingException;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.imageio.ImageIO;
import jd.http.URLConnectionAdapter.METHOD;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.logging.Log;
public abstract class Request {
// public static int MAX_REDIRECTS = 30;
/**
* Gibt eine Hashmap mit allen key:value pairs im query zurück
*
* @param query
* kann ein reines query ein (&key=value) oder eine url mit query
* @return
* @throws MalformedURLException
*/
public static LinkedHashMap<String, String> parseQuery(String query) throws MalformedURLException {
if (query == null) { return null; }
final LinkedHashMap<String, String> ret = new LinkedHashMap<String, String>();
if (query.toLowerCase().trim().startsWith("http")) {
query = new URL(query).getQuery();
}
if (query == null) { return ret; }
final String[][] split = new Regex(query.trim(), "&?(.*?)=(.*?)($|&(?=.*?=.+))").getMatches();
if (split != null) {
final int splitLength = split.length;
for (int i = 0; i < splitLength; i++) {
ret.put(split[i][0], split[i][1]);
}
}
return ret;
}
/*
* default timeouts, because 0 is infinite and BAD, if we need 0 then we
* have to set it manually
*/
private int connectTimeout = 30000;
private int readTimeout = 60000;
private Cookies cookies = null;
private RequestHeader headers;
private String htmlCode;
protected URLConnectionAdapter httpConnection;
private long readTime = -1;
private boolean requested = false;
private HTTPProxy proxy;
private URL orgURL;
private String customCharset = null;
private byte[] byteArray;
private BufferedImage image;
public void setCustomCharset(final String charset) {
this.customCharset = charset;
}
public Request(final String url) throws MalformedURLException {
this.orgURL = new URL(Browser.correctURL(url));
initDefaultHeader();
}
public void setProxy(final HTTPProxy proxy) {
this.proxy = proxy;
}
public HTTPProxy getProxy() {
return proxy;
}
public String printHeaders() {
return httpConnection.toString();
}
public Request(final URLConnectionAdapter con) {
httpConnection = con;
collectCookiesFromConnection();
}
private void collectCookiesFromConnection() {
final List<String> cookieHeaders = (List<String>) httpConnection.getHeaderFields().get("Set-Cookie");
final String date = httpConnection.getHeaderField("Date");
if (cookieHeaders == null) { return; }
if (cookies == null) {
cookies = new Cookies();
}
final String host = Browser.getHost(httpConnection.getURL());
for (int i = 0; i < cookieHeaders.size(); i++) {
final String header = cookieHeaders.get(i);
cookies.add(Cookies.parseCookies(header, host, date));
}
}
/**
* DO NEVER call this method directly... use browser.connect
*/
protected Request connect() throws IOException {
requested = true;
openConnection();
postRequest(httpConnection);
httpConnection.connect();
try {
collectCookiesFromConnection();
} catch (NullPointerException e) {
throw new IOException("Malformed url?", e);
}
return this;
}
public boolean containsHTML(final String html) throws CharacterCodingException {
return (getHtmlCode() == null) ? false : getHtmlCode().contains(html);
}
public void setCookies(final Cookies cookies) {
this.cookies = cookies;
}
public int getConnectTimeout() {
return connectTimeout;
}
public long getContentLength() {
return (httpConnection == null) ? -1 : httpConnection.getLongContentLength();
}
public Cookies getCookies() {
if (cookies == null) {
cookies = new Cookies();
}
return cookies;
}
// public static boolean isExpired(String cookie) {
// if (cookie == null) return false;
//
// try {
// return (new Date().compareTo()) > 0;
// } catch (Exception e) {
// return false;
// }
// }
public String getCookieString() {
return getCookieString(cookies);
}
public static String getCookieString(final Cookies cookies) {
if (cookies == null) { return null; }
final StringBuilder buffer = new StringBuilder();
boolean first = true;
final LinkedList<Cookie> cookies2 = new LinkedList<Cookie>(cookies.getCookies());
for (final Cookie cookie : cookies2) {
// Pfade sollten verarbeitet werden...TODO
if (cookie.isExpired()) {
continue;
}
if (first) {
first = false;
} else {
buffer.append("; ");
}
buffer.append(cookie.getKey());
buffer.append("=");
buffer.append(cookie.getValue());
}
return buffer.toString();
}
public RequestHeader getHeaders() {
return headers;
}
/**
* Will replace #getHtmlCode() with next release
*/
public String getResponseText() throws CharacterCodingException {
return getHtmlCode();
}
public String getHtmlCode() throws CharacterCodingException {
String ct = httpConnection.getContentType();
/* check for image content type */
if (ct != null && Pattern.compile("images?/\\w*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(ct).matches()) throw new IllegalStateException("Content-Type: " + ct);
if (htmlCode == null && byteArray != null) {
/* use custom charset or charset from httpconnection */
String useCS = customCharset == null ? this.httpConnection.getCharset() : customCharset;
try {
try {
try {
if (useCS != null) {
/* try to use wanted charset */
htmlCode = new String(byteArray, useCS.toUpperCase());
byteArray = null;
return htmlCode;
}
} catch (Exception e) {
}
htmlCode = new String(byteArray, "ISO-8859-1");
byteArray = null;
return htmlCode;
} catch (Exception e) {
Log.getLogger().severe("could neither charset: " + useCS + " nor default charset");
/* fallback to default charset in error case */
htmlCode = new String(byteArray);
byteArray = null;
return htmlCode;
}
} catch (Exception e) {
/* in case of error we do not reset byteArray */
}
}
return htmlCode;
}
public URLConnectionAdapter getHttpConnection() {
return httpConnection;
}
public String getLocation() {
if (httpConnection == null) { return null; }
String red = httpConnection.getHeaderField("Location");
final String encoding = httpConnection.getHeaderField("Content-Type");
if (red == null || red.length() == 0) return null;
if (encoding != null && encoding.contains("UTF-8")) {
red = Encoding.UTF8Decode(red, "ISO-8859-1");
}
try {
new URL(red);
} catch (Exception e) {
String path = this.getHttpConnection().getURL().getFile();
if (!path.endsWith("/")) {
int lastSlash = path.lastIndexOf("/");
if (lastSlash > 0) {
path = path.substring(0, path.lastIndexOf("/"));
} else {
path = "";
}
}
red = "http://" + this.getHttpConnection().getURL().getHost() + (red.charAt(0) == '/' ? red : path + "/" + red);
}
return Browser.correctURL(Encoding.urlEncode_light(red));
}
public long getReadTime() {
return readTime;
}
public int getReadTimeout() {
return readTimeout;
}
public long getRequestTime() {
return (httpConnection == null) ? -1 : httpConnection.getRequestTime();
}
public String getResponseHeader(final String key) {
return (httpConnection == null) ? null : httpConnection.getHeaderField(key);
}
public Map<String, List<String>> getResponseHeaders() {
return (httpConnection == null) ? null : httpConnection.getHeaderFields();
}
public URL getUrl() {
return orgURL;
}
private boolean hasCookies() {
return cookies != null && !cookies.isEmpty();
}
private void initDefaultHeader() {
headers = new RequestHeader();
headers.put("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10");
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
headers.put("Accept-Language", "de, en-gb;q=0.9, en;q=0.8");
if (JDUtilities.getJavaVersion() >= 1.6) {
/* deflate only java >=1.6 */
headers.put("Accept-Encoding", "gzip,deflate");
} else {
headers.put("Accept-Encoding", "gzip");
}
headers.put("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
headers.put("Cache-Control", "no-cache");
headers.put("Pragma", "no-cache");
headers.put("Connection", "close");
}
public boolean isRequested() {
return requested;
}
public String load() throws IOException {
requestConnection();
return getHtmlCode();
}
private void openConnection() throws IOException {
if (!headers.contains("Host")) {
if (orgURL.getPort() != 80 && orgURL.getPort() > 0) {
headers.setAt(0, "Host", orgURL.getHost() + ":" + orgURL.getPort());
} else {
headers.setAt(0, "Host", orgURL.getHost());
}
}
httpConnection = HTTPConnectionFactory.createHTTPConnection(orgURL, proxy);
httpConnection.setRequest(this);
httpConnection.setReadTimeout(readTimeout);
httpConnection.setConnectTimeout(connectTimeout);
if (headers != null) {
final int headersSize = headers.size();
for (int i = 0; i < headersSize; i++) {
httpConnection.setRequestProperty(headers.getKey(i), headers.getValue(i));
}
}
preRequest(httpConnection);
if (hasCookies()) {
httpConnection.setRequestProperty("Cookie", getCookieString());
}
}
public abstract long postRequest(URLConnectionAdapter httpConnection) throws IOException;
abstract public void preRequest(URLConnectionAdapter httpConnection) throws IOException;
public Request read() throws IOException {
long tima = System.currentTimeMillis();
httpConnection.setCharset(this.customCharset);
byteArray = read(httpConnection);
readTime = System.currentTimeMillis() - tima;
return this;
}
public static byte[] read(final URLConnectionAdapter con) throws IOException {
BufferedInputStream is = null;
if (con.getInputStream() != null) {
if (con.getHeaderField("Content-Encoding") != null && con.getHeaderField("Content-Encoding").equalsIgnoreCase("gzip")) {
is = new BufferedInputStream(new GZIPInputStream(con.getInputStream()));
} else if (con.getHeaderField("Content-Encoding") != null && con.getHeaderField("Content-Encoding").equalsIgnoreCase("deflate") && JDUtilities.getJavaVersion() >= 1.6) {
is = new BufferedInputStream(new java.util.zip.DeflaterInputStream(con.getInputStream()));
} else {
is = new BufferedInputStream(con.getInputStream());
}
}
if (is == null) {
// TODO: check if we have t close con here
return null;
}
ByteArrayOutputStream tmpOut;
long contentLength = con.getContentLength();
if (contentLength != -1) {
int length = contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) contentLength;
tmpOut = new ByteArrayOutputStream(length);
} else {
tmpOut = new ByteArrayOutputStream(16384);
}
byte[] preRead = con.preReadBytes();
if (preRead != null) {
tmpOut.write(preRead);
}
/* added "Corrupt GZIP trailer" for CamWinsCom */
try {
final byte[] b = new byte[1024];
int len;
while ((len = is.read(b)) != -1) {
tmpOut.write(b, 0, len);
}
} catch (EOFException e) {
jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE, "Try workaround for ", e);
} catch (IOException e) {
if (e.toString().contains("end of ZLIB") || e.toString().contains("Premature") || e.toString().contains("Corrupt GZIP trailer")) {
jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE, "Try workaround for ", e);
} else
throw e;
} finally {
try {
is.close();
} catch (Exception e) {
}
try {
tmpOut.close();
} catch (Exception e) {
}
try {
/* disconnect connection */
con.disconnect();
} catch (Exception e) {
}
}
return tmpOut.toByteArray();
}
private void requestConnection() throws IOException {
connect();
read();
}
public void setConnectTimeout(final int connectTimeout) {
this.connectTimeout = connectTimeout;
}
// public void setProxy(String ip, String port) throws
// NumberFormatException, MalformedURLException {
// proxyip = ip;
// proxyport = port;
// if (ip == null || port == null) return;
// url = new URL("http", proxyip, Integer.parseInt(proxyport),
// url.toString());
//
// }
public void setReadTimeout(final int readTimeout) {
this.readTimeout = readTimeout;
}
// @Override
public String toString() {
if (!requested) { return "Request not sent yet"; }
try {
getHtmlCode();
if (htmlCode == null || htmlCode.length() == 0) {
if (getLocation() != null) { return "Not HTML Code. Redirect to: " + getLocation(); }
return "No htmlCode read";
}
} catch (Exception e) {
return "NOTEXT: " + e.getMessage();
}
return this.htmlCode;
}
public void setHtmlCode(final String htmlCode) {
// set bytebuffer to null... user works with htmlcode
this.byteArray = null;
this.htmlCode = htmlCode;
}
public Request toHeadRequest() throws MalformedURLException {
final Request ret = new Request(this.getUrl() + "") {
// @Override
public long postRequest(URLConnectionAdapter httpConnection) throws IOException {
return 0;
}
// @Override
public void preRequest(URLConnectionAdapter httpConnection) throws IOException {
httpConnection.setRequestMethod(METHOD.HEAD);
}
};
ret.connectTimeout = this.connectTimeout;
ret.cookies = new Cookies(this.getCookies());
ret.headers = this.getHeaders().clone();
ret.setProxy(proxy);
ret.readTime = this.readTimeout;
ret.httpConnection = this.httpConnection;
return ret;
}
public Request cloneRequest() {
return null;
}
/**
* Returns the loaded bytes
*
* @return
*/
public byte[] getResponseBytes() {
if (byteArray != null) return byteArray.clone();
return null;
}
/**
* tries to generate an image out of the loaded bytes
*
* @return
*/
public Image getResponseImage() {
String ct = httpConnection.getContentType();
/* check for image content */
if (ct != null && !Pattern.compile("images?/\\w*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(ct).matches()) { throw new IllegalStateException("Content-Type: " + ct); }
// TODO..this is just quick and dirty.. may result in memory leaks
if (image == null && byteArray != null) {
InputStream fake = new ByteArrayInputStream(byteArray);
try {
image = ImageIO.read(fake);
// BasicWindow.showImage(image);
// its an immage;
byteArray = null;
} catch (Exception e) {
Log.exception(e);
}
}
return image;
}
}

View File

@ -1,202 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class RequestHeader {
/**
* For more header fields see
*
* @link(http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14).
*/
// request headers
public static final String ACCEPT = "Accept";
public static final String ACCEPT_CHARSET = "Accept-Charset";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
public static final String ACCEPT_LANGUAGE = "Accept-Language";
public static final String AUTHORIZATION = "Authorization";
public static final String CONNECTION = "Connection";
public static final String COOKIE = "Cookie";
public static final String EXPECT = "Expect";
public static final String FROM = "From";
public static final String HOST = "Host";
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
public static final String MAX_FORWARDS = "Max-Forwards";
public static final String RANGE = "Range";
public static final String REFERER = "Referer";
public static final String TE = "TE";
public static final String USER_AGENT = "User-Agent";
// response headers
public static final String ACCEPT_RANGES = "Accept-Ranges";
public static final String AGE = "Age";
public static final String LOCATION = "Location";
public static final String SERVER = "Server";
public static final String RETRY_AFTER = "Retry-After";
// entity headers
public static final String ALLOW = "Allow";
public static final String CACHE_CONTROL = "Cache-Control";
public static final String CONTENT_ENCODING = "Content-Encoding";
public static final String CONTENT_LANGUAGE = "Content-Language";
public static final String CONTENT_LENGTH = "Content-Length";
public static final String CONTENT_LOCATION = "Content-Location";
public static final String CONTENT_MD5 = "Content-MD5";
public static final String CONTENT_RANGE = "Content-Range";
public static final String CONTENT_TYPE = "Content-Type";
public static final String DATE = "Date";
public static final String EXPIRES = "Expires";
public static final String LAST_MODIFIED = "Last-Modified";
public static final String PRAGMA = "Pragma";
// AJAX headers
public static final String X_REQUESTED_WITH = "X-Requested-With";
// members
private final List<String> keys;
private final List<String> values;
private boolean dominant = false;
public RequestHeader() {
this.keys = new ArrayList<String>();
this.values = new ArrayList<String>();
}
public RequestHeader(final Map<String, String> headers) {
this();
this.putAll(headers);
}
/**
* if a header is dominant, it will not get merged with existing headers. It
* will replace it completely
*
* @param dominant
*/
public void setDominant(final boolean dominant) {
this.dominant = dominant;
}
public void put(final String key, final String value) {
final int keysSize = keys.size();
final String trim = key.trim();
for (int i = 0; i < keysSize; i++) {
if (keys.get(i).equalsIgnoreCase(trim)) {
keys.set(i, key);
values.set(i, value);
return;
}
}
keys.add(key);
values.add(value);
}
public String getKey(final int index) {
return keys.get(index);
}
public String getValue(final int index) {
return values.get(index);
}
public int size() {
return keys.size();
}
@Override
public RequestHeader clone() {
final RequestHeader newObj = new RequestHeader();
newObj.keys.addAll(keys);
newObj.values.addAll(values);
return newObj;
}
public String remove(final String key) {
final int index = keys.indexOf(key);
if (index >= 0) {
keys.remove(index);
return values.remove(index);
}
return null;
}
public void putAll(final Map<String, String> properties) {
for (final Entry<String, String> entry : properties.entrySet()) {
final String key = entry.getKey();
final String value = entry.getValue();
if (value == null) {
remove(key);
} else {
put(key, value);
}
}
}
public void putAll(final RequestHeader headers) {
final int size = headers.size();
for (int i = 0; i < size; i++) {
final String key = headers.getKey(i);
final String value = headers.getValue(i);
if (value == null) {
remove(key);
} else {
put(key, value);
}
}
}
public String get(final String key) {
final int index = keys.indexOf(key);
return (index >= 0) ? values.get(index) : null;
}
public void clear() {
keys.clear();
values.clear();
}
public boolean contains(final String string) {
return keys.contains(string);
}
public void setAt(final int index, final String key, final String value) {
if (keys.isEmpty()) {
this.put(key, value);
return;
}
keys.add(keys.get(keys.size() - 1));
values.add(values.get(values.size() - 1));
for (int e = keys.size() - 3; e >= index; e--) {
keys.set(e + 1, keys.get(e));
values.set(e + 1, values.get(e));
}
keys.set(index, key);
values.set(index, value);
}
public boolean isDominant() {
return dominant;
}
}

View File

@ -1,226 +0,0 @@
package jd.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import jd.parser.Regex;
public class Socks5HTTPConnection extends HTTPConnection {
protected Socket socks5socket = null;
protected InputStream socks5inputstream = null;
protected OutputStream socks5outputstream = null;
private int httpPort;
private String httpHost;
public Socks5HTTPConnection(URL url, HTTPProxy proxy) {
super(url, proxy);
}
protected int sayHello() throws IOException {
try {
/* socks5 */
socks5outputstream.write((byte) 5);
/* only none ans password/username auth method */
socks5outputstream.write((byte) 2);
/* none */
socks5outputstream.write((byte) 2);
/* username/password */
socks5outputstream.write((byte) 0);
socks5outputstream.flush();
/* read response, 2 bytes */
byte[] resp = readResponse(2);
if (resp[0] != 5) { throw new IOException("Socks5HTTPConnection: invalid Socks5 response"); }
if (resp[1] == 255) { throw new IOException("Socks5HTTPConnection: no acceptable authentication method found"); }
return resp[1];
} catch (IOException e) {
try {
socks5socket.close();
} catch (Throwable e2) {
}
throw e;
}
}
protected void authenticateProxy() throws IOException {
try {
String user = proxy.getUser() == null ? "" : proxy.getUser();
String pass = proxy.getPass() == null ? "" : proxy.getPass();
byte[] username = user.getBytes("UTF-8");
byte[] password = pass.getBytes("UTF-8");
/* must be 1 */
socks5outputstream.write((byte) 1);
/* send username */
socks5outputstream.write((byte) username.length);
socks5outputstream.write(username);
/* send password */
socks5outputstream.write((byte) password.length);
socks5outputstream.write(password);
/* read response, 2 bytes */
byte[] resp = readResponse(2);
if (resp[0] != 1) { throw new IOException("Socks5HTTPConnection: invalid Socks5 response"); }
if (resp[1] != 0) {
proxy.setStatus(HTTPProxy.STATUS.INVALIDAUTH);
throw new IOException("Socks5HTTPConnection: authentication failed");
}
} catch (IOException e) {
try {
socks5socket.close();
} catch (Throwable e2) {
}
throw e;
}
}
protected Socket establishConnection() throws IOException {
try {
/* socks5 */
socks5outputstream.write((byte) 5);
/* tcp/ip connection */
socks5outputstream.write((byte) 1);
/* reserved */
socks5outputstream.write((byte) 0);
/* we use domain names */
socks5outputstream.write((byte) 3);
/* send somain name */
byte[] domain = httpHost.getBytes("UTF-8");
socks5outputstream.write((byte) domain.length);
socks5outputstream.write(domain);
/* send port */
/* network byte order */
socks5outputstream.write((httpPort >> 8) & 0xff);
socks5outputstream.write(httpPort & 0xff);
socks5outputstream.flush();
/* read response, 4 bytes and then read rest of response */
byte[] resp = readResponse(4);
if (resp[0] != 5) { throw new IOException("Socks5HTTPConnection: invalid Socks5 response"); }
switch (resp[1]) {
case 0:
default:
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
throw new IOException("Socks5HTTPConnection: could not establish connection, status=" + resp[1]);
}
if (resp[3] == 1) {
/* ip4v response */
readResponse(4 + 2);
} else if (resp[3] == 3) {
/* domain name response */
readResponse(1 + domain.length + 2);
} else
throw new IOException("Socks5HTTPConnection: unsupported address Type " + resp[3]);
return socks5socket;
} catch (IOException e) {
try {
socks5socket.close();
} catch (Throwable e2) {
}
throw e;
}
}
/* reads response with expLength bytes */
protected byte[] readResponse(int expLength) throws IOException {
byte[] response = new byte[expLength];
int index = 0;
int read = 0;
while ((index < expLength) && (read = socks5inputstream.read()) != -1) {
response[index] = (byte) read;
index++;
}
if (index < expLength) { throw new IOException("Socks5HTTPConnection: not enough data read"); }
return response;
}
@Override
public void connect() throws IOException {
if (isConnected()) return;/* oder fehler */
if (proxy == null || !proxy.getType().equals(HTTPProxy.TYPE.SOCKS5)) { throw new IOException("Socks5HTTPConnection: invalid Socks5 Proxy!"); }
/* create and connect to socks5 proxy */
socks5socket = createSocket();
socks5socket.setSoTimeout(readTimeout);
long startTime = System.currentTimeMillis();
socks5socket.connect(new InetSocketAddress(proxy.getHost(), proxy.getPort()), connectTimeout);
socks5inputstream = socks5socket.getInputStream();
socks5outputstream = socks5socket.getOutputStream();
/* establish connection to socks5 */
int method = sayHello();
if (method == 2) {
/* username/password authentication */
authenticateProxy();
}
/* establish to destination through socks5 */
httpPort = httpURL.getPort();
httpHost = httpURL.getHost();
if (httpPort == -1) httpPort = httpURL.getDefaultPort();
Socket establishedConnection = establishConnection();
if (httpURL.getProtocol().startsWith("https")) {
/* we need to lay ssl over normal socks5 connection */
SSLSocket sslSocket = null;
try {
SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
sslSocket = (SSLSocket) socketFactory.createSocket(establishedConnection, httpHost, httpPort, true);
sslSocket.startHandshake();
} catch (SSLHandshakeException e) {
try {
socks5socket.close();
} catch (Throwable e2) {
}
throw new IOException("Socks5HTTPConnection: " + e);
}
httpSocket = sslSocket;
} else {
/* we can continue to use the socks5 connection */
httpSocket = establishedConnection;
}
httpResponseCode = -1;
requestTime = System.currentTimeMillis() - startTime;
httpPath = new Regex(httpURL.toString(), "https?://.*?(/.+)").getMatch(0);
if (httpPath == null) httpPath = "/";
/* now send Request */
StringBuilder sb = new StringBuilder();
sb.append(httpMethod.name()).append(' ').append(httpPath).append(" HTTP/1.1\r\n");
for (String key : this.requestProperties.keySet()) {
if (requestProperties.get(key) == null) continue;
sb.append(key).append(": ").append(requestProperties.get(key)).append("\r\n");
}
sb.append("\r\n");
httpSocket.getOutputStream().write(sb.toString().getBytes("UTF-8"));
httpSocket.getOutputStream().flush();
if (httpMethod != METHOD.POST) {
outputClosed = true;
connectInputStream();
}
}
@Override
public void disconnect() {
if (isConnected()) {
try {
httpSocket.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
try {
socks5socket.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
}

View File

@ -1,98 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
public interface URLConnectionAdapter {
public static enum METHOD {
GET, POST, HEAD
}
Map<String, List<String>> getHeaderFields();
String getHeaderField(String string);
URL getURL();
int getContentLength();
long getLongContentLength();
void setReadTimeout(int readTimeout);
void setConnectTimeout(int connectTimeout);
void setRequestProperty(String key, String string);
InputStream getInputStream() throws IOException;
void setRequestMethod(METHOD method);
METHOD getRequestMethod();
void connect() throws IOException;
OutputStream getOutputStream() throws IOException;
Map<String, String> getRequestProperties();
boolean isOK();
long[] getRange();
String getResponseMessage();
int getResponseCode();
void disconnect();
String getContentType();
boolean isConnected();
String getRequestProperty(String string);
boolean isContentDisposition();
void setRequest(Request request);
public Request getRequest();
public String getCharset();
public void setCharset(String charset);
public long getRequestTime();
/**
* returns bytearray that belongs to content, WARNING will get null after
* first call
*
* @return
*/
public byte[] preReadBytes();
/* needs to get called after postData is send */
public void postDataSend() throws IOException;
}

View File

@ -1,111 +0,0 @@
/**
* The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
* Software Development Kit for iControl"; you may not use this file except in
* compliance with the License. The License is included in the iControl
* Software Development Kit.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is iControl Code and related documentation
* distributed by F5.
*
* Portions created by F5 are Copyright (C) 1996-2004 F5 Networks
* Inc. All Rights Reserved. iControl (TM) is a registered trademark of
* F5 Networks, Inc.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU General Public License (the "GPL"), in which case the
* provisions of GPL are applicable instead of those above. If you wish
* to allow use of your version of this file only under the terms of the
* GPL and not to allow others to use your version of this file under the
* License, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the GPL.
* If you do not delete the provisions above, a recipient may use your
* version of this file under either the License or the GPL.
*/
package jd.http;
import java.security.AccessController;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
import java.security.cert.X509Certificate;
import javax.net.ssl.ManagerFactoryParameters;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactorySpi;
import javax.net.ssl.X509TrustManager;
public final class XTrustProvider extends Provider {
private static final long serialVersionUID = -4201108498101335796L;
private static String oldalgo = null;
private final static String NAME = "XTrustJSSE";
private final static String INFO = "XTrust JSSE Provider (implements trust factory with truststore validation disabled)";
private final static double VERSION = 1.0D;
public XTrustProvider() {
super(NAME, VERSION, INFO);
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
put("TrustManagerFactory." + TrustManagerFactoryImpl.getAlgorithm(), TrustManagerFactoryImpl.class.getName());
return null;
}
});
}
public static void install() {
if (Security.getProvider(NAME) == null) {
Security.insertProviderAt(new XTrustProvider(), 2);
oldalgo = Security.getProperty("ssl.TrustManagerFactory.algorithm");
Security.setProperty("ssl.TrustManagerFactory.algorithm", TrustManagerFactoryImpl.getAlgorithm());
}
}
public static void remove() {
if (Security.getProvider(NAME) != null) {
Security.removeProvider("XTrustJSSE");
Security.setProperty("ssl.TrustManagerFactory.algorithm", oldalgo);
oldalgo = null;
}
}
public final static class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
public TrustManagerFactoryImpl() {
}
public static String getAlgorithm() {
return "XTrust509";
}
protected void engineInit(KeyStore keystore) throws KeyStoreException {
}
protected void engineInit(ManagerFactoryParameters mgrparams) throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException(XTrustProvider.NAME + " does not use ManagerFactoryParameters");
}
protected TrustManager[] engineGetTrustManagers() {
return new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
} };
}
}
}

View File

@ -10,8 +10,8 @@ import jd.http.ext.events.ExtBrowserListener;
import jd.http.ext.events.JSInteraction;
import jd.http.ext.interfaces.BrowserEnviroment;
import jd.http.ext.security.JSPermissionRestricter;
import jd.parser.Regex;
import org.appwork.utils.Regex;
import org.appwork.utils.logging.Log;
import org.lobobrowser.html.UserAgentContext;
import org.lobobrowser.html.domimpl.HTMLDocumentImpl;

View File

@ -13,10 +13,10 @@ import java.util.Iterator;
import jd.http.Browser;
import jd.http.Request;
import jd.parser.Regex;
import jd.parser.html.Form;
import jd.parser.html.InputField;
import org.appwork.utils.Regex;
import org.appwork.utils.logging.Log;
import org.lobobrowser.html.BrowserFrame;
import org.lobobrowser.html.FormInput;

View File

@ -2,8 +2,7 @@ package jd.http.ext;
import java.util.ArrayList;
import jd.parser.Regex;
import org.appwork.utils.Regex;
import org.lobobrowser.html.domimpl.HTMLElementImpl;
import org.lobobrowser.html.style.AbstractCSS2Properties;

View File

@ -1,94 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http.requests;
import java.io.File;
public class FormData {
private final Type type;
private String name;
private final String value;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getValue() {
return value;
}
public byte[] getData() {
return data;
}
public File getFile() {
return file;
}
private byte[] data;
private File file;
private String mime;
public FormData(final String name, final String value) {
this.type = Type.VARIABLE;
this.name = name;
this.value = value;
}
public FormData(final String name, final String filename, final byte[] data) {
this(name, filename, null, data);
}
public FormData(final String name, final String filename, final String mime, final byte[] data) {
this.mime = (mime == null) ? "application/octet-stream" : mime;
this.type = Type.DATA;
this.name = name;
this.value = filename;
this.data = data;
}
public FormData(final String name, final String filename, final File file) {
this(name, filename, null, file);
}
public FormData(final String name, final String filename, final String mime, final File file) {
this.mime = (mime == null) ? "application/octet-stream" : mime;
this.type = Type.FILE;
this.name = name;
this.value = filename;
this.file = file;
}
public static enum Type {
VARIABLE, FILE, DATA
}
public Type getType() {
return type;
}
public String getDataType() {
return this.mime;
}
}

View File

@ -1,42 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http.requests;
import java.io.IOException;
import java.net.MalformedURLException;
import jd.http.Browser;
import jd.http.Request;
import jd.http.URLConnectionAdapter;
import jd.http.URLConnectionAdapter.METHOD;
public class GetRequest extends Request {
public GetRequest(String url) throws MalformedURLException {
super(Browser.correctURL(url));
}
public long postRequest(URLConnectionAdapter httpConnection) throws IOException {
return 0;
}
public void preRequest(URLConnectionAdapter httpConnection) throws IOException {
httpConnection.setRequestMethod(METHOD.GET);
}
}

View File

@ -1,177 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http.requests;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.util.ArrayList;
import jd.http.Browser;
import jd.http.Request;
import jd.http.URLConnectionAdapter;
import jd.http.URLConnectionAdapter.METHOD;
import org.appwork.utils.net.CountingOutputStream;
import org.appwork.utils.net.NullOutputStream;
/**
* Extending the Request class, this class is able to to HTML Formdata Posts.
*
* @author coalado
*/
public class PostFormDataRequest extends Request {
private String boundary;
private ArrayList<FormData> formDatas;
private String encodeType = "multipart/form-data";
public String getEncodeType() {
return encodeType;
}
public void setEncodeType(String encodeType) {
this.encodeType = encodeType;
}
public PostFormDataRequest(String url) throws MalformedURLException {
super(Browser.correctURL(url));
generateBoundary();
this.formDatas = new ArrayList<FormData>();
}
/**
* send the postData of the Request. in case httpConnection is null, it
* outputs the data to a NullOutputStream
*/
public long postRequest(URLConnectionAdapter httpConnection) throws IOException {
CountingOutputStream output = null;
if (httpConnection != null && httpConnection.getOutputStream() != null) {
output = new CountingOutputStream(httpConnection.getOutputStream());
} else {
output = new CountingOutputStream(new NullOutputStream());
}
try {
for (int i = 0; i < this.formDatas.size(); i++) {
write(formDatas.get(i), output);
}
OutputStreamWriter writer = new OutputStreamWriter(output);
writer.write(this.boundary);
writer.write("--\r\n");
writer.flush();
output.flush();
} finally {
if (httpConnection != null) httpConnection.postDataSend();
}
return output.bytesWritten();
}
private void write(FormData formData, OutputStream output) throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(output);
writer.write(this.boundary);
writer.write("\r\n");
switch (formData.getType()) {
case VARIABLE:
writer.write("Content-Disposition: form-data; name=\"" + formData.getName() + "\"");
writer.write("\r\n\r\n");
writer.write(formData.getValue() + "\r\n");
break;
case DATA:
writer.write("Content-Disposition: form-data; name=\"" + formData.getName() + "\"; filename=\"" + formData.getValue() + "\"");
writer.write("\r\nContent-Type: " + formData.getDataType() + "\r\n\r\n");
writer.flush();
output.write(formData.getData(), 0, formData.getData().length);
output.flush();
writer.write("\r\n");
writer.flush();
break;
case FILE:
writer.write("Content-Disposition: form-data; name=\"" + formData.getName() + "\"; filename=\"" + formData.getValue() + "\"");
writer.write("\r\nContent-Type: " + formData.getDataType() + "\r\n\r\n");
writer.flush();
byte[] b = new byte[1024];
InputStream in = null;
try {
in = new FileInputStream(formData.getFile());
int n;
while ((n = in.read(b)) > -1) {
output.write(b, 0, n);
}
output.flush();
writer.write("\r\n");
writer.flush();
} finally {
if (in != null) in.close();
}
break;
}
writer.flush();
output.flush();
}
public void preRequest(URLConnectionAdapter httpConnection) throws IOException {
httpConnection.setRequestMethod(METHOD.POST);
httpConnection.setRequestProperty("Content-Type", encodeType + "; boundary=" + boundary.substring(2));
httpConnection.setRequestProperty("Content-Length", this.postRequest(null) + "");
}
private void generateBoundary() {
long range = (999999999999999l - 100000000000000l);
long rand = (long) (Math.random() * range) + 100000000000000l;
boundary = "---------------------" + rand;
}
public void addFormData(FormData fd) {
this.formDatas.add(fd);
}
public String getPostDataString() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < this.formDatas.size(); i++) {
write(formDatas.get(i), sb);
}
sb.append(this.boundary);
sb.append("--\r\n");
return sb.toString();
}
private void write(FormData formData, StringBuffer sb) {
sb.append(this.boundary);
sb.append("\r\n");
switch (formData.getType()) {
case VARIABLE:
sb.append("Content-Disposition: form-data; name=\"").append(formData.getName()).append("\"");
sb.append("\r\n\r\n");
sb.append(formData.getValue()).append("\r\n");
break;
case DATA:
sb.append("Content-Disposition: form-data; name=\"").append(formData.getName()).append("\"; filename=\"").append(formData.getValue()).append("\"");
sb.append("\r\nContent-Type: ").append(formData.getDataType());
sb.append("\r\n\r\n[.....").append(formData.getData().length).append(" Byte DATA....]\r\n");
break;
case FILE:
sb.append("Content-Disposition: form-data; name=\"").append(formData.getName()).append("\"; filename=\"").append(formData.getValue()).append("\"");
sb.append("\r\nContent-Type: ").append(formData.getDataType());
sb.append("\r\n\r\n[.....").append(formData.getFile().length()).append(" FileByte DATA....]\r\n");
break;
}
}
}

View File

@ -1,139 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http.requests;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import org.appwork.utils.net.CountingOutputStream;
import org.appwork.utils.net.NullOutputStream;
import jd.http.Browser;
import jd.http.Request;
import jd.http.URLConnectionAdapter;
import jd.http.URLConnectionAdapter.METHOD;
import jd.parser.html.Form;
public class PostRequest extends Request {
private ArrayList<RequestVariable> postData;
private String postDataString = null;
private String contentType = null;
public PostRequest(final Form form) throws MalformedURLException {
super(form.getAction(null));
postData = new ArrayList<RequestVariable>();
}
public PostRequest(final String url) throws MalformedURLException {
super(Browser.correctURL(url));
postData = new ArrayList<RequestVariable>();
}
public String getPostDataString() {
if (postData.isEmpty()) { return postDataString; }
final StringBuilder buffer = new StringBuilder();
for (final RequestVariable rv : postData) {
if (rv.getKey() != null) {
buffer.append("&");
buffer.append(rv.getKey());
buffer.append("=");
if (rv.getValue() != null) {
buffer.append(rv.getValue());
} else {
buffer.append("");
}
}
}
if (buffer.length() == 0) return "";
return buffer.substring(1);
}
public void setPostDataString(final String post) {
this.postDataString = post;
}
/**
* send the postData of the Request. in case httpConnection is null, it
* outputs the data to a NullOutputStream
*/
public long postRequest(final URLConnectionAdapter httpConnection) throws IOException {
CountingOutputStream output = null;
if (httpConnection != null && httpConnection.getOutputStream() != null) {
output = new CountingOutputStream(httpConnection.getOutputStream());
} else {
output = new CountingOutputStream(new NullOutputStream());
}
String parameter = postDataString != null ? postDataString : getPostDataString();
try {
if (parameter != null) {
if (postDataString == null) parameter = parameter.trim();
final OutputStreamWriter wr = new OutputStreamWriter(output);
if (parameter != null) {
wr.write(parameter);
}
wr.flush();
output.flush();
}
} finally {
if (httpConnection != null) httpConnection.postDataSend();
}
return output.bytesWritten();
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public void preRequest(final URLConnectionAdapter httpConnection) throws IOException {
httpConnection.setRequestMethod(METHOD.POST);
if (contentType != null) httpConnection.setRequestProperty("Content-Type", contentType);
String parameter = postDataString != null ? postDataString : getPostDataString();
if (parameter != null) {
httpConnection.setRequestProperty("Content-Length", this.postRequest(null) + "");
} else {
httpConnection.setRequestProperty("Content-Length", "0");
}
}
public void addVariable(final String key, final String value) {
postData.add(new RequestVariable(key, value));
}
public static ArrayList<RequestVariable> variableMaptoArray(final LinkedHashMap<String, String> post) {
if (post == null) return null;
final ArrayList<RequestVariable> ret = new ArrayList<RequestVariable>();
for (final Entry<String, String> entry : post.entrySet()) {
ret.add(new RequestVariable(entry.getKey(), entry.getValue()));
}
return ret;
}
public void addAll(final HashMap<String, String> post) {
for (final Entry<String, String> entry : post.entrySet()) {
this.postData.add(new RequestVariable(entry));
}
}
public void addAll(final ArrayList<RequestVariable> post) {
this.postData.addAll(post);
}
}

View File

@ -1,51 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.http.requests;
import java.util.Map.Entry;
public class RequestVariable {
private String key;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public RequestVariable(String key, String value) {
this.key = key;
this.value = value;
}
public RequestVariable(Entry<String, String> keyValueEntry) {
this.key = keyValueEntry.getKey();
this.value = keyValueEntry.getValue();
}
}

View File

@ -24,6 +24,8 @@ import java.util.SimpleTimeZone;
import jd.nutils.encoding.Encoding;
import org.appwork.utils.formatter.StringFormatter;
public class Formatter {
/**
@ -107,16 +109,11 @@ public class Formatter {
return fileSize + " B";
}
/**
* @deprecated Use {@link StringFormatter#fillString(String,String,String,int)} instead
*/
public static String fillString(String binaryString, String pre, String post, int length) {
while (binaryString.length() < length) {
if (binaryString.length() < length) {
binaryString = pre + binaryString;
}
if (binaryString.length() < length) {
binaryString = binaryString + post;
}
}
return binaryString;
return StringFormatter.fillString(binaryString, pre, post, length);
}
/**

View File

@ -53,8 +53,8 @@ import java.util.StringTokenizer;
import jd.controlling.DownloadWatchDog;
import jd.controlling.JDLogger;
import jd.parser.Regex;
import org.appwork.utils.Regex;
import org.appwork.utils.event.Eventsender;
import org.appwork.utils.net.throttledconnection.MeteredThrottledInputStream;
import org.appwork.utils.speedmeter.AverageSpeedMeter;

View File

@ -1,575 +0,0 @@
package jd.nutils.encoding;
import java.util.Arrays;
/** A very fast and memory efficient class to encode and decode to and from BASE64 in full accordance
* with RFC 2045.<br><br>
* On Windows XP sp1 with 1.4.2_04 and later ;), this encoder and decoder is about 10 times faster
* on small arrays (10 - 1000 bytes) and 2-3 times as fast on larger arrays (10000 - 1000000 bytes)
* compared to <code>sun.misc.Encoder()/Decoder()</code>.<br><br>
*
* On byte arrays the encoder is about 20% faster than Jakarta Commons Base64 Codec for encode and
* about 50% faster for decoding large arrays. This implementation is about twice as fast on very small
* arrays (&lt 30 bytes). If source/destination is a <code>String</code> this
* version is about three times as fast due to the fact that the Commons Codec result has to be recoded
* to a <code>String</code> from <code>byte[]</code>, which is very expensive.<br><br>
*
* This encode/decode algorithm doesn't create any temporary arrays as many other codecs do, it only
* allocates the resulting array. This produces less garbage and it is possible to handle arrays twice
* as large as algorithms that create a temporary array. (E.g. Jakarta Commons Codec). It is unknown
* whether Sun's <code>sun.misc.Encoder()/Decoder()</code> produce temporary arrays but since performance
* is quite low it probably does.<br><br>
*
* The encoder produces the same output as the Sun one except that the Sun's encoder appends
* a trailing line separator if the last character isn't a pad. Unclear why but it only adds to the
* length and is probably a side effect. Both are in conformance with RFC 2045 though.<br>
* Commons codec seem to always att a trailing line separator.<br><br>
*
* <b>Note!</b>
* The encode/decode method pairs (types) come in three versions with the <b>exact</b> same algorithm and
* thus a lot of code redundancy. This is to not create any temporary arrays for transcoding to/from different
* format types. The methods not used can simply be commented out.<br><br>
*
* There is also a "fast" version of all decode methods that works the same way as the normal ones, but
* har a few demands on the decoded input. Normally though, these fast verions should be used if the source if
* the input is known and it hasn't bee tampered with.<br><br>
*
* If you find the code useful or you find a bug, please send me a note at base64 @ miginfocom . com.
*
* Licence (BSD):
* ==============
*
* Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (base64 @ miginfocom . com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
* Neither the name of the MiG InfoCom AB nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* @version 2.2
* @author Mikael Grev
* Date: 2004-aug-02
* Time: 11:31:11
*/
public class Base64
{
private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
private static final int[] IA = new int[256];
static {
Arrays.fill(IA, -1);
for (int i = 0, iS = CA.length; i < iS; i++)
IA[CA[i]] = i;
IA['='] = 0;
}
// ****************************************************************************************
// * char[] version
// ****************************************************************************************
/** Encodes a raw byte array into a BASE64 <code>char[]</code> representation i accordance with RFC 2045.
* @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned.
* @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br>
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a
* little faster.
* @return A BASE64 encoded array. Never <code>null</code>.
*/
public final static char[] encodeToChar(byte[] sArr, boolean lineSep)
{
// Check special case
int sLen = sArr != null ? sArr.length : 0;
if (sLen == 0)
return new char[0];
int eLen = (sLen / 3) * 3; // Length of even 24-bits.
int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count
int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array
char[] dArr = new char[dLen];
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = CA[(i >>> 18) & 0x3f];
dArr[d++] = CA[(i >>> 12) & 0x3f];
dArr[d++] = CA[(i >>> 6) & 0x3f];
dArr[d++] = CA[i & 0x3f];
// Add optional line separator
if (lineSep && ++cc == 19 && d < dLen - 2) {
dArr[d++] = '\r';
dArr[d++] = '\n';
cc = 0;
}
}
// Pad and encode last bits if source isn't even 24 bits.
int left = sLen - eLen; // 0 - 2.
if (left > 0) {
// Prepare the int
int i = ((sArr[eLen] & 0xff) << 10) | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0);
// Set last four chars
dArr[dLen - 4] = CA[i >> 12];
dArr[dLen - 3] = CA[(i >>> 6) & 0x3f];
dArr[dLen - 2] = left == 2 ? CA[i & 0x3f] : '=';
dArr[dLen - 1] = '=';
}
return dArr;
}
/** Decodes a BASE64 encoded char array. All illegal characters will be ignored and can handle both arrays with
* and without line separators.
* @param sArr The source array. <code>null</code> or length 0 will return an empty array.
* @return The decoded array of bytes. May be of length 0. Will be <code>null</code> if the legal characters
* (including '=') isn't divideable by 4. (I.e. definitely corrupted).
*/
public final static byte[] decode(char[] sArr)
{
// Check special case
int sLen = sArr != null ? sArr.length : 0;
if (sLen == 0)
return new byte[0];
// Count illegal characters (including '\r', '\n') to know what size the returned array will be,
// so we don't have to reallocate & copy it later.
int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...)
for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out.
if (IA[sArr[i]] < 0)
sepCnt++;
// Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045.
if ((sLen - sepCnt) % 4 != 0)
return null;
int pad = 0;
for (int i = sLen; i > 1 && IA[sArr[--i]] <= 0;)
if (sArr[i] == '=')
pad++;
int len = ((sLen - sepCnt) * 6 >> 3) - pad;
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
for (int s = 0, d = 0; d < len;) {
// Assemble three bytes into an int from four "valid" characters.
int i = 0;
for (int j = 0; j < 4; j++) { // j only increased if a valid char was found.
int c = IA[sArr[s++]];
if (c >= 0)
i |= c << (18 - j * 6);
else
j--;
}
// Add the bytes
dArr[d++] = (byte) (i >> 16);
if (d < len) {
dArr[d++]= (byte) (i >> 8);
if (d < len)
dArr[d++] = (byte) i;
}
}
return dArr;
}
/** Decodes a BASE64 encoded char array that is known to be resonably well formatted. The method is about twice as
* fast as {@link #decode(char[])}. The preconditions are:<br>
* + The array must have a line length of 76 chars OR no line separators at all (one line).<br>
* + Line separator must be "\r\n", as specified in RFC 2045
* + The array must not contain illegal characters within the encoded string<br>
* + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.<br>
* @param sArr The source array. Length 0 will return an empty array. <code>null</code> will throw an exception.
* @return The decoded array of bytes. May be of length 0.
*/
public final static byte[] decodeFast(char[] sArr)
{
// Check special case
int sLen = sArr.length;
if (sLen == 0)
return new byte[0];
int sIx = 0, eIx = sLen - 1; // Start and end index after trimming.
// Trim illegal chars from start
while (sIx < eIx && IA[sArr[sIx]] < 0)
sIx++;
// Trim illegal chars from end
while (eIx > 0 && IA[sArr[eIx]] < 0)
eIx--;
// get the padding count (=) (0, 1 or 2)
int pad = sArr[eIx] == '=' ? (sArr[eIx - 1] == '=' ? 2 : 1) : 0; // Count '=' at end.
int cCnt = eIx - sIx + 1; // Content count including possible separators
int sepCnt = sLen > 76 ? (sArr[76] == '\r' ? cCnt / 78 : 0) << 1 : 0;
int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
// Decode all but the last 0 - 2 bytes.
int d = 0;
for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) {
// Assemble three bytes into an int from four "valid" characters.
int i = IA[sArr[sIx++]] << 18 | IA[sArr[sIx++]] << 12 | IA[sArr[sIx++]] << 6 | IA[sArr[sIx++]];
// Add the bytes
dArr[d++] = (byte) (i >> 16);
dArr[d++] = (byte) (i >> 8);
dArr[d++] = (byte) i;
// If line separator, jump over it.
if (sepCnt > 0 && ++cc == 19) {
sIx += 2;
cc = 0;
}
}
if (d < len) {
// Decode last 1-3 bytes (incl '=') into 1-3 bytes
int i = 0;
for (int j = 0; sIx <= eIx - pad; j++)
i |= IA[sArr[sIx++]] << (18 - j * 6);
for (int r = 16; d < len; r -= 8)
dArr[d++] = (byte) (i >> r);
}
return dArr;
}
// ****************************************************************************************
// * byte[] version
// ****************************************************************************************
/** Encodes a raw byte array into a BASE64 <code>byte[]</code> representation i accordance with RFC 2045.
* @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned.
* @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br>
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a
* little faster.
* @return A BASE64 encoded array. Never <code>null</code>.
*/
public final static byte[] encodeToByte(byte[] sArr, boolean lineSep)
{
// Check special case
int sLen = sArr != null ? sArr.length : 0;
if (sLen == 0)
return new byte[0];
int eLen = (sLen / 3) * 3; // Length of even 24-bits.
int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count
int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array
byte[] dArr = new byte[dLen];
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = (byte) CA[(i >>> 18) & 0x3f];
dArr[d++] = (byte) CA[(i >>> 12) & 0x3f];
dArr[d++] = (byte) CA[(i >>> 6) & 0x3f];
dArr[d++] = (byte) CA[i & 0x3f];
// Add optional line separator
if (lineSep && ++cc == 19 && d < dLen - 2) {
dArr[d++] = '\r';
dArr[d++] = '\n';
cc = 0;
}
}
// Pad and encode last bits if source isn't an even 24 bits.
int left = sLen - eLen; // 0 - 2.
if (left > 0) {
// Prepare the int
int i = ((sArr[eLen] & 0xff) << 10) | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0);
// Set last four chars
dArr[dLen - 4] = (byte) CA[i >> 12];
dArr[dLen - 3] = (byte) CA[(i >>> 6) & 0x3f];
dArr[dLen - 2] = left == 2 ? (byte) CA[i & 0x3f] : (byte) '=';
dArr[dLen - 1] = '=';
}
return dArr;
}
/** Decodes a BASE64 encoded byte array. All illegal characters will be ignored and can handle both arrays with
* and without line separators.
* @param sArr The source array. Length 0 will return an empty array. <code>null</code> will throw an exception.
* @return The decoded array of bytes. May be of length 0. Will be <code>null</code> if the legal characters
* (including '=') isn't divideable by 4. (I.e. definitely corrupted).
*/
public final static byte[] decode(byte[] sArr)
{
// Check special case
int sLen = sArr.length;
// Count illegal characters (including '\r', '\n') to know what size the returned array will be,
// so we don't have to reallocate & copy it later.
int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...)
for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out.
if (IA[sArr[i] & 0xff] < 0)
sepCnt++;
// Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045.
if ((sLen - sepCnt) % 4 != 0)
return null;
int pad = 0;
for (int i = sLen; i > 1 && IA[sArr[--i] & 0xff] <= 0;)
if (sArr[i] == '=')
pad++;
int len = ((sLen - sepCnt) * 6 >> 3) - pad;
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
for (int s = 0, d = 0; d < len;) {
// Assemble three bytes into an int from four "valid" characters.
int i = 0;
for (int j = 0; j < 4; j++) { // j only increased if a valid char was found.
int c = IA[sArr[s++] & 0xff];
if (c >= 0)
i |= c << (18 - j * 6);
else
j--;
}
// Add the bytes
dArr[d++] = (byte) (i >> 16);
if (d < len) {
dArr[d++]= (byte) (i >> 8);
if (d < len)
dArr[d++] = (byte) i;
}
}
return dArr;
}
/** Decodes a BASE64 encoded byte array that is known to be resonably well formatted. The method is about twice as
* fast as {@link #decode(byte[])}. The preconditions are:<br>
* + The array must have a line length of 76 chars OR no line separators at all (one line).<br>
* + Line separator must be "\r\n", as specified in RFC 2045
* + The array must not contain illegal characters within the encoded string<br>
* + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.<br>
* @param sArr The source array. Length 0 will return an empty array. <code>null</code> will throw an exception.
* @return The decoded array of bytes. May be of length 0.
*/
public final static byte[] decodeFast(byte[] sArr)
{
// Check special case
int sLen = sArr.length;
if (sLen == 0)
return new byte[0];
int sIx = 0, eIx = sLen - 1; // Start and end index after trimming.
// Trim illegal chars from start
while (sIx < eIx && IA[sArr[sIx] & 0xff] < 0)
sIx++;
// Trim illegal chars from end
while (eIx > 0 && IA[sArr[eIx] & 0xff] < 0)
eIx--;
// get the padding count (=) (0, 1 or 2)
int pad = sArr[eIx] == '=' ? (sArr[eIx - 1] == '=' ? 2 : 1) : 0; // Count '=' at end.
int cCnt = eIx - sIx + 1; // Content count including possible separators
int sepCnt = sLen > 76 ? (sArr[76] == '\r' ? cCnt / 78 : 0) << 1 : 0;
int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
// Decode all but the last 0 - 2 bytes.
int d = 0;
for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) {
// Assemble three bytes into an int from four "valid" characters.
int i = IA[sArr[sIx++]] << 18 | IA[sArr[sIx++]] << 12 | IA[sArr[sIx++]] << 6 | IA[sArr[sIx++]];
// Add the bytes
dArr[d++] = (byte) (i >> 16);
dArr[d++] = (byte) (i >> 8);
dArr[d++] = (byte) i;
// If line separator, jump over it.
if (sepCnt > 0 && ++cc == 19) {
sIx += 2;
cc = 0;
}
}
if (d < len) {
// Decode last 1-3 bytes (incl '=') into 1-3 bytes
int i = 0;
for (int j = 0; sIx <= eIx - pad; j++)
i |= IA[sArr[sIx++]] << (18 - j * 6);
for (int r = 16; d < len; r -= 8)
dArr[d++] = (byte) (i >> r);
}
return dArr;
}
// ****************************************************************************************
// * String version
// ****************************************************************************************
/** Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045.
* @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned.
* @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br>
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a
* little faster.
* @return A BASE64 encoded array. Never <code>null</code>.
*/
public final static String encodeToString(byte[] sArr, boolean lineSep)
{
// Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower.
return new String(encodeToChar(sArr, lineSep));
}
/** Decodes a BASE64 encoded <code>String</code>. All illegal characters will be ignored and can handle both strings with
* and without line separators.<br>
* <b>Note!</b> It can be up to about 2x the speed to call <code>decode(str.toCharArray())</code> instead. That
* will create a temporary array though. This version will use <code>str.charAt(i)</code> to iterate the string.
* @param str The source string. <code>null</code> or length 0 will return an empty array.
* @return The decoded array of bytes. May be of length 0. Will be <code>null</code> if the legal characters
* (including '=') isn't divideable by 4. (I.e. definitely corrupted).
*/
public final static byte[] decode(String str)
{
// Check special case
int sLen = str != null ? str.length() : 0;
if (sLen == 0)
return new byte[0];
// Count illegal characters (including '\r', '\n') to know what size the returned array will be,
// so we don't have to reallocate & copy it later.
int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...)
for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out.
if (IA[str.charAt(i)] < 0)
sepCnt++;
// Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045.
if ((sLen - sepCnt) % 4 != 0)
return null;
// Count '=' at end
int pad = 0;
for (int i = sLen; i > 1 && IA[str.charAt(--i)] <= 0;)
if (str.charAt(i) == '=')
pad++;
int len = ((sLen - sepCnt) * 6 >> 3) - pad;
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
for (int s = 0, d = 0; d < len;) {
// Assemble three bytes into an int from four "valid" characters.
int i = 0;
for (int j = 0; j < 4; j++) { // j only increased if a valid char was found.
int c = IA[str.charAt(s++)];
if (c >= 0)
i |= c << (18 - j * 6);
else
j--;
}
// Add the bytes
dArr[d++] = (byte) (i >> 16);
if (d < len) {
dArr[d++]= (byte) (i >> 8);
if (d < len)
dArr[d++] = (byte) i;
}
}
return dArr;
}
/** Decodes a BASE64 encoded string that is known to be resonably well formatted. The method is about twice as
* fast as {@link #decode(String)}. The preconditions are:<br>
* + The array must have a line length of 76 chars OR no line separators at all (one line).<br>
* + Line separator must be "\r\n", as specified in RFC 2045
* + The array must not contain illegal characters within the encoded string<br>
* + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.<br>
* @param s The source string. Length 0 will return an empty array. <code>null</code> will throw an exception.
* @return The decoded array of bytes. May be of length 0.
*/
public final static byte[] decodeFast(String s)
{
// Check special case
int sLen = s.length();
if (sLen == 0)
return new byte[0];
int sIx = 0, eIx = sLen - 1; // Start and end index after trimming.
// Trim illegal chars from start
while (sIx < eIx && IA[s.charAt(sIx) & 0xff] < 0)
sIx++;
// Trim illegal chars from end
while (eIx > 0 && IA[s.charAt(eIx) & 0xff] < 0)
eIx--;
// get the padding count (=) (0, 1 or 2)
int pad = s.charAt(eIx) == '=' ? (s.charAt(eIx - 1) == '=' ? 2 : 1) : 0; // Count '=' at end.
int cCnt = eIx - sIx + 1; // Content count including possible separators
int sepCnt = sLen > 76 ? (s.charAt(76) == '\r' ? cCnt / 78 : 0) << 1 : 0;
int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
// Decode all but the last 0 - 2 bytes.
int d = 0;
for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) {
// Assemble three bytes into an int from four "valid" characters.
int i = IA[s.charAt(sIx++)] << 18 | IA[s.charAt(sIx++)] << 12 | IA[s.charAt(sIx++)] << 6 | IA[s.charAt(sIx++)];
// Add the bytes
dArr[d++] = (byte) (i >> 16);
dArr[d++] = (byte) (i >> 8);
dArr[d++] = (byte) i;
// If line separator, jump over it.
if (sepCnt > 0 && ++cc == 19) {
sIx += 2;
cc = 0;
}
}
if (d < len) {
// Decode last 1-3 bytes (incl '=') into 1-3 bytes
int i = 0;
for (int j = 0; sIx <= eIx - pad; j++)
i |= IA[s.charAt(sIx++)] << (18 - j * 6);
for (int r = 16; d < len; r -= 8)
dArr[d++] = (byte) (i >> r);
}
return dArr;
}
}

View File

@ -1,293 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.nutils.encoding;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import jd.controlling.JDLogger;
public class Encoding {
public static byte[] base16Decode(String code) {
while (code.length() % 2 > 0)
code += "0";
byte[] res = new byte[code.length() / 2];
int i = 0;
while (i < code.length()) {
res[i / 2] = (byte) Integer.parseInt(code.substring(i, i + 2), 16);
i += 2;
}
return res;
}
/**
* "http://rapidshare.com&#x2F;&#x66;&#x69;&#x6C;&#x65;&#x73;&#x2F;&#x35;&#x34;&#x35;&#x34;&#x31;&#x34;&#x38;&#x35;&#x2F;&#x63;&#x63;&#x66;&#x32;&#x72;&#x73;&#x64;&#x66;&#x2E;&#x72;&#x61;&#x72;"
* ; Wandelt alle hexkodierten zeichen in diesem Format in normalen text um
*
* @param str
* @return decoded string
*/
public static String htmlDecode(String str) {
if (str == null) return null;
try {
str = URLDecoder.decode(str, "UTF-8");
} catch (Exception e) {
JDLogger.exception(e);
}
return htmlOnlyDecode(str);
}
public static String htmlOnlyDecode(String str) {
if (str == null) return null;
str = HTMLEntities.unhtmlentities(str);
str = HTMLEntities.unhtmlAmpersand(str);
str = HTMLEntities.unhtmlAngleBrackets(str);
str = HTMLEntities.unhtmlDoubleQuotes(str);
str = HTMLEntities.unhtmlQuotes(str);
str = HTMLEntities.unhtmlSingleQuotes(str);
return str;
}
/**
* WARNING: we MUST use the encoding given in charset info by webserver!
* else missmatch will happen eg UTF8 vs ISO-8859-15
**/
public static String urlEncode(String str) {
if (str == null) return null;
try {
return URLEncoder.encode(str, "UTF-8");
} catch (Exception e) {
JDLogger.exception(e);
}
return str;
}
public static boolean isUrlCoded(String str) {
if (str == null) return false;
try {
if (URLDecoder.decode(str, "UTF-8").length() != str.length()) {
return true;
} else
return false;
} catch (Exception e) {
return false;
}
}
/**
* WARNING: we MUST use the encoding given in charset info by webserver!
* else missmatch will happen eg UTF8 vs ISO-8859-15
**/
public static String formEncoding(String str) {
/* Form Variablen dürfen keine Leerzeichen haben */
if (str == null) return null;
if (isUrlCoded(str)) {
return str.replaceAll(" ", "+");
} else
return urlEncode(str);
}
public static String urlEncode_light(String url) {
if (url == null) return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < url.length(); i++) {
char ch = url.charAt(i);
if (ch == ' ') {
sb.append("%20");
} else if (ch >= 33 && ch <= 38) {
sb.append(ch);
continue;
} else if (ch >= 40 && ch <= 59) {
sb.append(ch);
continue;
} else if (ch == 61) {
sb.append(ch);
continue;
} else if (ch >= 63 && ch <= 95) {
sb.append(ch);
continue;
} else if (ch >= 97 && ch <= 126) {
sb.append(ch);
continue;
} else {
try {
sb.append(URLEncoder.encode(String.valueOf(ch), "UTF-8"));
} catch (Exception e) {
JDLogger.exception(e);
return url;
}
}
}
return sb.toString();
}
public static String urlDecode(String urlcoded, boolean isUrl) {
if (urlcoded == null) return null;
if (isUrl) {
urlcoded = urlcoded.replaceAll("%2F", "/");
urlcoded = urlcoded.replaceAll("%3A", ":");
urlcoded = urlcoded.replaceAll("%3F", "?");
urlcoded = urlcoded.replaceAll("%3D", "=");
urlcoded = urlcoded.replaceAll("%26", "&");
urlcoded = urlcoded.replaceAll("%23", "#");
} else {
try {
urlcoded = URLDecoder.decode(urlcoded, "UTF-8");
} catch (Exception e) {
JDLogger.exception(e);
}
}
return urlcoded;
}
/**
* @author JD-Team
* @param str
* @return str als UTF8Decodiert
*/
public static String UTF8Decode(String str) {
return UTF8Decode(str, null);
}
public static String UTF8Decode(String str, String sourceEncoding) {
if (str == null) { return null; }
try {
if (sourceEncoding != null) {
return new String(str.getBytes(sourceEncoding), "UTF-8");
} else {
return new String(str.getBytes(), "UTF-8");
}
} catch (UnsupportedEncodingException e) {
JDLogger.exception(e);
return str;
}
}
/**
* @author JD-Team
* @param str
* @return str als UTF8 Kodiert
*/
public static String UTF8Encode(String str) {
try {
return new String(str.getBytes("UTF-8"));
} catch (Exception e) {
JDLogger.exception(e);
return null;
}
}
public static String Base64Decode(String base64) {
if (base64 == null) { return null; }
try {
byte[] plain = Base64.decode(base64);
if (Encoding.filterString(new String(plain)).length() < plain.length / 1.5) { return base64; }
return new String(plain);
} catch (Exception e) {
return base64;
}
}
public static String Base64Encode(String plain) {
if (plain == null) { return null; }
// String base64 = new BASE64Encoder().encode(plain.getBytes());
String base64 = new String(Base64.encodeToByte(plain.getBytes(), false));
return base64;
}
/**
* Filtert alle nicht lesbaren zeichen aus str
*
* @param str
* @return
*/
public static String filterString(String str) {
String allowed = "QWERTZUIOPÜASDFGHJKLÖÄYXCVBNMqwertzuiopasdfghjklyxcvbnmöäü;:,._-&$%(){}#~+ 1234567890<>='\"/";
return Encoding.filterString(str, allowed);
}
/**
* Filtert alle zeichen aus str die in filter nicht auftauchen
*
* @param str
* @param filter
* @return
*/
public static String filterString(String str, String filter) {
if (str == null || filter == null) { return ""; }
byte[] org = str.getBytes();
byte[] mask = filter.getBytes();
byte[] ret = new byte[org.length];
int count = 0;
int i;
for (i = 0; i < org.length; i++) {
byte letter = org[i];
for (byte element : mask) {
if (letter == element) {
ret[count] = letter;
count++;
break;
}
}
}
return new String(ret).trim();
}
/**
* Wenden htmlDecode an, bis es keine Änderungen mehr gibt. Aber max 50 mal!
*
* @param string
* @return
*/
public static String deepHtmlDecode(String string) {
String decoded, tmp;
tmp = Encoding.htmlDecode(string);
int i = 50;
while (!tmp.equals(decoded = Encoding.htmlDecode(tmp))) {
tmp = decoded;
if (i-- <= 0) {
System.err.println("Max Decodeingloop 50 reached!!!");
return tmp;
}
}
return tmp;
}
public static String urlTotalEncode(String string) {
byte[] org = string.getBytes();
StringBuilder sb = new StringBuilder();
String code;
for (int i = 0; i < org.length; i++) {
sb.append('%');
code = Integer.toHexString(org[i]);
sb.append(code.substring(code.length() - 2));
}
return sb + "";
}
}

View File

@ -1,328 +0,0 @@
package jd.nutils.encoding;
import java.util.Hashtable;
/**
* Collection of static methods to convert special and extended characters into
* HTML entitities and vice versa.<br>
* <br>
* Copyright (c) 2004-2005 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo
* n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com -
* info@tecnick.com<br>
* Project homepage: <a href="http://htmlentities.sourceforge.net"
* target="_blank">http://htmlentities.sourceforge.net</a><br>
* License: http://www.gnu.org/copyleft/lesser.html LGPL
*
* @author Nicola Asuni [www.tecnick.com].
* @version 1.0.004
*
*
* Changes by JD-Team:
*
* added htmlTotal Method
*/
public class HTMLEntities {
/**
* Translation table for HTML entities.<br>
* reference: W3C - Character entity references in HTML 4 [<a
* href="http://www.w3.org/TR/html401/sgml/entities.html"
* target="_blank">http://www.w3.org/TR/html401/sgml/entities.html</a>].
*/
private static final Object[][] html_entities_table = { { "&Aacute;", 193 }, { "&aacute;", 225 }, { "&Acirc;", 194 }, { "&acirc;", 226 }, { "&acute;", 180 }, { "&AElig;", 198 }, { "&aelig;", 230 }, { "&Agrave;", 192 }, { "&agrave;", 224 }, { "&alefsym;", 8501 }, { "&Alpha;", 913 }, { "&alpha;", 945 }, { "&amp;", 38 }, { "&and;", 8743 }, { "&ang;", 8736 }, { "&Aring;", 197 }, { "&aring;", 229 }, { "&asymp;", 8776 },
{ "&Atilde;", 195 }, { "&atilde;", 227 }, { "&Auml;", 196 }, { "&auml;", 228 }, { "&bdquo;", 8222 }, { "&Beta;", 914 }, { "&beta;", 946 }, { "&brvbar;", 166 }, { "&bull;", 8226 }, { "&cap;", 8745 }, { "&Ccedil;", 199 }, { "&ccedil;", 231 }, { "&cedil;", 184 }, { "&cent;", 162 }, { "&Chi;", 935 }, { "&chi;", 967 }, { "&circ;", 710 }, { "&clubs;", 9827 }, { "&cong;", 8773 },
{ "&copy;", 169 }, { "&crarr;", 8629 }, { "&cup;", 8746 }, { "&curren;", 164 }, { "&dagger;", 8224 }, { "&Dagger;", 8225 }, { "&darr;", 8595 }, { "&dArr;", 8659 }, { "&deg;", 176 }, { "&Delta;", 916 }, { "&delta;", 948 }, { "&diams;", 9830 }, { "&divide;", 247 }, { "&Eacute;", 201 }, { "&eacute;", 233 }, { "&Ecirc;", 202 }, { "&ecirc;", 234 }, { "&Egrave;", 200 }, { "&egrave;", 232 },
{ "&empty;", 8709 }, { "&emsp;", 8195 }, { "&ensp;", 8194 }, { "&Epsilon;", 917 }, { "&epsilon;", 949 }, { "&equiv;", 8801 }, { "&Eta;", 919 }, { "&eta;", 951 }, { "&ETH;", 208 }, { "&eth;", 240 }, { "&Euml;", 203 }, { "&euml;", 235 }, { "&euro;", 8364 }, { "&exist;", 8707 }, { "&fnof;", 402 }, { "&forall;", 8704 }, { "&frac12;", 189 }, { "&frac14;", 188 }, { "&frac34;", 190 },
{ "&frasl;", 8260 }, { "&Gamma;", 915 }, { "&gamma;", 947 }, { "&ge;", 8805 }, { "&harr;", 8596 }, { "&hArr;", 8660 }, { "&hearts;", 9829 }, { "&hellip;", 8230 }, { "&Iacute;", 205 }, { "&iacute;", 237 }, { "&Icirc;", 206 }, { "&icirc;", 238 }, { "&iexcl;", 161 }, { "&Igrave;", 204 }, { "&igrave;", 236 }, { "&image;", 8465 }, { "&infin;", 8734 }, { "&int;", 8747 }, { "&Iota;", 921 },
{ "&iota;", 953 }, { "&iquest;", 191 }, { "&isin;", 8712 }, { "&Iuml;", 207 }, { "&iuml;", 239 }, { "&Kappa;", 922 }, { "&kappa;", 954 }, { "&Lambda;", 923 }, { "&lambda;", 955 }, { "&lang;", 9001 }, { "&laquo;", 171 }, { "&larr;", 8592 }, { "&lArr;", 8656 }, { "&lceil;", 8968 }, { "&ldquo;", 8220 }, { "&le;", 8804 }, { "&lfloor;", 8970 }, { "&lowast;", 8727 }, { "&loz;", 9674 },
{ "&lrm;", 8206 }, { "&lsaquo;", 8249 }, { "&lsquo;", 8216 }, { "&macr;", 175 }, { "&mdash;", 8212 }, { "&micro;", 181 }, { "&middot;", 183 }, { "&minus;", 8722 }, { "&Mu;", 924 }, { "&mu;", 956 }, { "&nabla;", 8711 }, { "&nbsp;", 160 }, { "&ndash;", 8211 }, { "&ne;", 8800 }, { "&ni;", 8715 }, { "&not;", 172 }, { "&notin;", 8713 }, { "&nsub;", 8836 }, { "&Ntilde;", 209 },
{ "&ntilde;", 241 }, { "&Nu;", 925 }, { "&nu;", 957 }, { "&Oacute;", 211 }, { "&oacute;", 243 }, { "&Ocirc;", 212 }, { "&ocirc;", 244 }, { "&OElig;", 338 }, { "&oelig;", 339 }, { "&Ograve;", 210 }, { "&ograve;", 242 }, { "&oline;", 8254 }, { "&Omega;", 937 }, { "&omega;", 969 }, { "&Omicron;", 927 }, { "&omicron;", 959 }, { "&oplus;", 8853 }, { "&or;", 8744 }, { "&ordf;", 170 },
{ "&ordm;", 186 }, { "&Oslash;", 216 }, { "&oslash;", 248 }, { "&Otilde;", 213 }, { "&otilde;", 245 }, { "&otimes;", 8855 }, { "&Ouml;", 214 }, { "&ouml;", 246 }, { "&para;", 182 }, { "&part;", 8706 }, { "&permil;", 8240 }, { "&perp;", 8869 }, { "&Phi;", 934 }, { "&phi;", 966 }, { "&Pi;", 928 }, { "&pi;", 960 }, { "&piv;", 982 }, { "&plusmn;", 177 }, { "&pound;", 163 },
{ "&prime;", 8242 }, { "&Prime;", 8243 }, { "&prod;", 8719 }, { "&prop;", 8733 }, { "&Psi;", 936 }, { "&psi;", 968 }, { "&radic;", 8730 }, { "&rang;", 9002 }, { "&raquo;", 187 }, { "&rarr;", 8594 }, { "&rArr;", 8658 }, { "&rceil;", 8969 }, { "&rdquo;", 8221 }, { "&real;", 8476 }, { "&reg;", 174 }, { "&rfloor;", 8971 }, { "&Rho;", 929 }, { "&rho;", 961 }, { "&rlm;", 8207 },
{ "&rsaquo;", 8250 }, { "&rsquo;", 8217 }, { "&sbquo;", 8218 }, { "&Scaron;", 352 }, { "&scaron;", 353 }, { "&sdot;", 8901 }, { "&sect;", 167 }, { "&shy;", 173 }, { "&Sigma;", 931 }, { "&sigma;", 963 }, { "&sigmaf;", 962 }, { "&sim;", 8764 }, { "&spades;", 9824 }, { "&sub;", 8834 }, { "&sube;", 8838 }, { "&sum;", 8721 }, { "&sup1;", 185 }, { "&sup2;", 178 }, { "&sup3;", 179 },
{ "&sup;", 8835 }, { "&supe;", 8839 }, { "&szlig;", 223 }, { "&Tau;", 932 }, { "&tau;", 964 }, { "&there4;", 8756 }, { "&Theta;", 920 }, { "&theta;", 952 }, { "&thetasym;", 977 }, { "&thinsp;", 8201 }, { "&THORN;", 222 }, { "&thorn;", 254 }, { "&tilde;", 732 }, { "&times;", 215 }, { "&trade;", 8482 }, { "&Uacute;", 218 }, { "&uacute;", 250 }, { "&uarr;", 8593 }, { "&uArr;", 8657 },
{ "&Ucirc;", 219 }, { "&ucirc;", 251 }, { "&Ugrave;", 217 }, { "&ugrave;", 249 }, { "&uml;", 168 }, { "&upsih;", 978 }, { "&Upsilon;", 933 }, { "&upsilon;", 965 }, { "&Uuml;", 220 }, { "&uuml;", 252 }, { "&weierp;", 8472 }, { "&Xi;", 926 }, { "&xi;", 958 }, { "&Yacute;", 221 }, { "&yacute;", 253 }, { "&yen;", 165 }, { "&yuml;", 255 }, { "&Yuml;", 376 }, { "&Zeta;", 918 },
{ "&zeta;", 950 }, { "&zwj;", 8205 }, { "&zwnj;", 8204 } };
/**
* Map to convert extended characters in html entities.
*/
private static final Hashtable<Integer, String> htmlentities_map = new Hashtable<Integer, String>();
/**
* Map to convert html entities in exteden characters.
*/
private static final Hashtable<String, Integer> unhtmlentities_map = new Hashtable<String, Integer>();
// ==========================================================================
// ====
// METHODS
// ==========================================================================
// ====
/**
* Get the html entities translation table.
*
* @return translation table
*/
public static Object[][] getEntitiesTable() {
return html_entities_table;
}
/**
* Replace &amp; characters with &amp;amp; HTML entities.
*
* @param str
* the input string
* @return string with replaced characters
*/
public static String htmlAmpersand(String str) {
return str.replaceAll("&", "&amp;");
}
/**
* Replace &lt; &gt; characters with &amp;lt; &amp;gt; entities.
*
* @param str
* the input string
* @return string with replaced characters
*/
public static String htmlAngleBrackets(String str) {
str = str.replaceAll("<", "&lt;");
str = str.replaceAll(">", "&gt;");
return str;
}
/**
* Replace double quotes characters with HTML entities.
*
* @param str
* the input string
* @return string with replaced double quotes
*/
public static String htmlDoubleQuotes(String str) {
str = str.replaceAll("[\"]", "&quot;");
str = str.replaceAll("&#147;", "&quot;");
str = str.replaceAll("&#148;", "&quot;");
return str;
}
/**
* Convert special and extended characters into HTML entitities.
*
* @param str
* input string
* @return formatted string
* @see #unhtmlentities(String)
*/
public static String htmlentities(String str) {
if (str == null) { return ""; }
// initialize html translation maps table the first time is called
if (htmlentities_map.isEmpty()) {
HTMLEntities.initializeEntitiesTables();
}
StringBuilder buf = new StringBuilder(); // the otput string buffer
for (int i = 0; i < str.length(); ++i) {
char ch = str.charAt(i);
String entity = htmlentities_map.get(new Integer(ch)); // get
// equivalent
// html
// entity
if (entity == null) { // if entity has not been found
if (ch > 128) { // check if is an extended character
buf.append("&#" + (int) ch + ";"); // convert extended
// character
} else {
buf.append(ch); // append the character as is
}
} else {
buf.append(entity); // append the html entity
}
}
return buf.toString();
}
// methods to convert special characters
/**
* Replace single and double quotes characters with HTML entities.
*
* @param str
* the input string
* @return string with replaced quotes
*/
public static String htmlQuotes(String str) {
str = HTMLEntities.htmlDoubleQuotes(str); // convert double quotes
str = HTMLEntities.htmlSingleQuotes(str); // convert single quotes
return str;
}
/**
* Replace single quotes characters with HTML entities.
*
* @param str
* the input string
* @return string with replaced single quotes
*/
public static String htmlSingleQuotes(String str) {
str = str.replaceAll("[\']", "&rsquo;");
str = str.replaceAll("&#039;", "&rsquo;");
str = str.replaceAll("&#145;", "&rsquo;");
str = str.replaceAll("&#146;", "&rsquo;");
return str;
}
/**
* Initialize HTML entities table.
*/
private static void initializeEntitiesTables() {
// initialize html translation maps
for (int i = 0; i < html_entities_table.length; ++i) {
htmlentities_map.put((Integer) html_entities_table[i][1], (String) html_entities_table[i][0]);
unhtmlentities_map.put((String) html_entities_table[i][0], (Integer) html_entities_table[i][1]);
}
}
/**
* Replace &amp;amp; HTML entities with &amp; characters.
*
* @param str
* the input string
* @return string with replaced entities
*/
public static String unhtmlAmpersand(String str) {
return str.replaceAll("&amp;", "&");
}
/**
* Replace &amp;lt; &amp;gt; entities with &lt; &gt; characters.
*
* @param str
* the input string
* @return string with replaced entities
*/
public static String unhtmlAngleBrackets(String str) {
str = str.replaceAll("&lt;", "<");
str = str.replaceAll("&gt;", ">");
return str;
}
/**
* Replace single quotes HTML entities with equivalent character.
*
* @param str
* the input string
* @return string with replaced single quotes
*/
public static String unhtmlDoubleQuotes(String str) {
return str.replaceAll("&quot;", "\"");
}
/**
* Convert HTML entities to special and extended unicode characters
* equivalents.
*
* @param str
* input string
* @return formatted string
* @see #htmlentities(String)
*/
public static String unhtmlentities(String str) {
if (str == null) return null;
// initialize html translation maps table the first time is called
if (htmlentities_map.isEmpty()) {
HTMLEntities.initializeEntitiesTables();
}
StringBuilder buf = new StringBuilder();
for (int i = 0; i < str.length(); ++i) {
char ch = str.charAt(i);
if (ch == '&') {
int semi = str.indexOf(';', i + 1);
if (semi == -1 || semi - i > 7) {
buf.append(ch);
continue;
}
String entity = str.substring(i, semi + 1);
Integer iso;
if (entity.charAt(1) == ' ') {
buf.append(ch);
continue;
}
if (entity.charAt(1) == '#') {
if (entity.charAt(2) == 'x') {
iso = new Integer(Integer.parseInt(entity.substring(3, entity.length() - 1), 16));
} else {
iso = new Integer(entity.substring(2, entity.length() - 1));
}
} else {
iso = unhtmlentities_map.get(entity);
}
if (iso == null) {
buf.append(entity);
} else {
buf.append((char) iso.intValue());
}
i = semi;
} else {
buf.append(ch);
}
}
return buf.toString();
}
/**
* Replace single and double quotes HTML entities with equivalent
* characters.
*
* @param str
* the input string
* @return string with replaced quotes
*/
public static String unhtmlQuotes(String str) {
str = HTMLEntities.unhtmlDoubleQuotes(str); // convert double quotes
str = HTMLEntities.unhtmlSingleQuotes(str); // convert single quotes
return str;
}
/**
* Replace single quotes HTML entities with equivalent character.
*
* @param str
* the input string
* @return string with replaced single quotes
*/
public static String unhtmlSingleQuotes(String str) {
return str.replaceAll("&rsquo;", "\'");
}
/**
* Initialize HTML translation maps.
*/
public HTMLEntities() {
HTMLEntities.initializeEntitiesTables();
}
/**
* @author JD-Team coalado
* @param format
* @return
*/
public static String htmlTotal(String format) {
format=HTMLEntities.htmlentities(format);
format=HTMLEntities.htmlAmpersand(format);
format=HTMLEntities.htmlAngleBrackets(format);
format=HTMLEntities.htmlDoubleQuotes(format);
format=HTMLEntities.htmlQuotes(format);
format=HTMLEntities.htmlSingleQuotes(format);
return format;
}
}

View File

@ -20,9 +20,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
public class FileSignatures {
/**

View File

@ -39,9 +39,10 @@ import java.util.regex.Pattern;
import javax.swing.JFileChooser;
import jd.controlling.JDLogger;
import jd.parser.Regex;
import jd.utils.StringUtil;
import org.appwork.utils.Regex;
public final class JDIO {
/**
* Don't let anyone instantiate this class.

View File

@ -27,8 +27,8 @@ import jd.controlling.JDLogger;
import jd.gui.swing.jdgui.JDGuiConstants;
import jd.nutils.Executer;
import jd.nutils.OSDetector;
import jd.parser.Regex;
import org.appwork.utils.Regex;
import org.appwork.utils.swing.dialog.Dialog;
import edu.stanford.ejalbert.BrowserLauncher;

View File

@ -25,7 +25,7 @@ import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import jd.parser.Regex;
import org.appwork.utils.Regex;
public class Zip {
private File destinationFile;

View File

@ -1,102 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.parser;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.appwork.utils.formatter.SizeFormatter;
/**
* TODO: Remove with next major update and change to
* {@link org.appwork.utils.Regex}
*/
public class Regex extends org.appwork.utils.Regex {
public static long getMilliSeconds(final String wait) {
String[][] matches = new Regex(wait, "([\\d]+) ?[\\.|\\,|\\:] ?([\\d]+)").getMatches();
if (matches == null || matches.length == 0) {
matches = new Regex(wait, Pattern.compile("([\\d]+)")).getMatches();
}
if (matches == null || matches.length == 0) { return -1; }
double res = 0;
if (matches[0].length == 1) {
res = Double.parseDouble(matches[0][0]);
}
if (matches[0].length == 2) {
res = Double.parseDouble(matches[0][0] + "." + matches[0][1]);
}
if (org.appwork.utils.Regex.matches(wait, Pattern.compile("(h|st)", Pattern.CASE_INSENSITIVE))) {
res *= 60 * 60 * 1000l;
} else if (org.appwork.utils.Regex.matches(wait, Pattern.compile("(m)", Pattern.CASE_INSENSITIVE))) {
res *= 60 * 1000l;
} else {
res *= 1000l;
}
return Math.round(res);
}
public static long getMilliSeconds(final String expire, final String timeformat, final Locale l) {
if (expire != null) {
final SimpleDateFormat dateFormat = l != null ? new SimpleDateFormat(timeformat, l) : new SimpleDateFormat(timeformat);
try {
return dateFormat.parse(expire).getTime();
} catch (final Exception e) {
e.printStackTrace();
}
}
return -1;
}
public static long getSize(final String string) {
return SizeFormatter.getSize(string);
}
public Regex(final Matcher matcher) {
super(matcher);
}
public Regex(final Object data, final Pattern pattern) {
super(data, pattern);
}
public Regex(final Object data, final String pattern) {
super(data, pattern);
}
public Regex(final Object data, final String pattern, final int flags) {
super(data, pattern, flags);
}
public Regex(final String data, final Pattern pattern) {
super(data, pattern);
}
public Regex(final String data, final String pattern) {
super(data, pattern);
}
public Regex(final String data, final String pattern, final int flags) {
super(data, pattern, flags);
}
}

View File

@ -1,549 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.parser.html;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jd.config.Property;
import jd.controlling.JDLogger;
import jd.http.requests.RequestVariable;
import jd.parser.Regex;
import jd.utils.EditDistance;
public class Form extends Property {
/**
*
*/
private static final long serialVersionUID = 5837247484638868257L;
public enum MethodType {
GET, POST, PUT, UNKNOWN
}
/**
* Action der Form entspricht auch oft einer URL
*/
private String action;
private ArrayList<InputField> inputfields;
private String htmlcode = null;
private MethodType method = MethodType.GET;
/* default encoding for http forms */
private String encoding = "application/x-www-form-urlencoded";
private InputField preferredSubmit;
public Form(String total) {
this();
parse(total);
}
public Form() {
this.inputfields = new ArrayList<InputField>();
}
private void parse(String total) {
htmlcode = total;
// form.baseRequest = requestInfo;
String header = new Regex(total, "<[\\s]*form(.*?)>").getMatch(0);
//
// <[\\s]*form(.*?)>(.*?)<[\\s]*/[\\s]*form[\\s]*>|<[\\s]*form(.*?)>(.+)
String[][] headerEntries = new Regex(header, "[\"' ](\\w+?)[ ]*=[ ]*[\"'](.*?)[\"']").getMatches();
String[][] headerEntries2 = new Regex(header, "[\"' ](\\w+?)[ ]*=[ ]*([^>^ ^\"^']+)").getMatches();
parseHeader(headerEntries);
parseHeader(headerEntries2);
this.parseInputFields();
// if (form.action == null) {
// form.action =
// requestInfo.getConnection().getURL().toString();
// }
// form.vars.add(form.getInputFields(inForm));
}
private void parseHeader(String[][] headerEntries) {
String key;
String value;
String lowvalue;
for (String[] entry : headerEntries) {
key = entry[0];
value = entry[1];
lowvalue = value.toLowerCase();
if (key.equalsIgnoreCase("action")) {
setAction(value);
} else if (key.equalsIgnoreCase("enctype")) {
this.setEncoding(value);
} else if (key.equalsIgnoreCase("method")) {
if (lowvalue.matches(".*post.*")) {
setMethod(MethodType.POST);
} else if (lowvalue.matches(".*get.*")) {
setMethod(MethodType.GET);
} else if (lowvalue.matches(".*put.*")) {
setMethod(MethodType.PUT);
} else {
setMethod(MethodType.POST);
}
} else {
this.setProperty(key, value);
}
}
}
public ArrayList<InputField> getInputFields() {
return inputfields;
}
public void setMethod(MethodType method) {
this.method = method;
}
public MethodType getMethod() {
return method;
}
public String getHtmlCode() {
return htmlcode;
}
public boolean equalsIgnoreCase(Form f) {
return this.toString().equalsIgnoreCase(f.toString());
}
/**
* Ein Array mit allen Forms dessen Inhalt dem matcher entspricht. Achtung
* der Matcher bezieht sich nicht auf die Properties einer Form sondern auf
* den Text der zwischen der Form steht. Dafür gibt es die formProperties
*/
public static Form[] getForms(Object requestInfo) {
LinkedList<Form> forms = new LinkedList<Form>();
Pattern pattern = Pattern.compile("<[\\s]*form(.*?)>(.*?)<[\\s]*/[\\s]*form[\\s]*>|<[\\s]*form(.*?)>(.+)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher formmatcher = pattern.matcher(requestInfo.toString().replaceAll("(?s)<!--.*?-->", ""));
while (formmatcher.find()) {
String total = formmatcher.group(0);
// System.out.println(inForm);
Form form = new Form(total);
forms.add(form);
}
return forms.toArray(new Form[forms.size()]);
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
// public boolean hasSubmitValue(String value) {
// for (String submit : this.submitValues) {
// try {
// if (submit == value || submit.equalsIgnoreCase(value)) return true;
// } catch (NullPointerException e) {
// //
// jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE,
// "Exception occurred",e);
// }
// }
// return false;
//
// }
public String getAction(String baseURL) {
URL baseurl = null;
if (baseURL == null) {
baseurl = null;
} else {
try {
baseurl = new URL(baseURL);
} catch (MalformedURLException e) {
JDLogger.exception(e);
}
}
String ret = action;
if (action == null || action.matches("[\\s]*")) {
if (baseurl == null) return null;
ret = baseurl.toString();
} else if (!ret.matches("https?://.*")) {
if (baseurl == null) { return null; }
if (ret.charAt(0) == '/') {
if (baseurl.getPort() > 0 && baseurl.getPort() != 80) {
ret = "http://" + baseurl.getHost() + ":" + baseurl.getPort() + ret;
} else {
ret = "http://" + baseurl.getHost() + ret;
}
} else if (ret.charAt(0) == '&') {
String base = baseurl.toString();
if (base.matches("http://.*/.*")) {
ret = base + ret;
} else {
ret = base + "/" + ret;
}
} else if (ret.charAt(0) == '?') {
String base = baseurl.toString();
if (base.matches("http://.*/.*")) {
ret = base.replaceFirst("\\?.*", "") + ret;
} else {
ret = base + "/" + ret;
}
} else if (ret.charAt(0) == '#') {
String base = baseurl.toString();
if (base.matches("http://.*/.*")) {
ret = base + ret;
} else {
ret = base + "/" + ret;
}
} else {
String base = baseurl.toString();
if (base.matches("http://.*/.*")) {
ret = base.substring(0, base.lastIndexOf("/")) + "/" + ret;
} else {
ret = base + "/" + ret;
}
}
}
return ret;
}
private void parseInputFields() {
inputfields = new ArrayList<InputField>();
Matcher matcher = Pattern.compile("(?s)(<[\\s]*(input|textarea|select).*?>)", Pattern.CASE_INSENSITIVE).matcher(this.htmlcode);
while (matcher.find()) {
InputField nv = InputField.parse(matcher.group(1));
if (nv != null) {
this.addInputField(nv);
}
}
}
public void addInputField(InputField nv) {
inputfields.add(nv);
}
public void addInputFieldAt(InputField nv, int i) {
inputfields.add(i, nv);
}
/**
* Changes the value of the first filed with the key key to value. if no
* field exists, a new one is created.
*
* @param key
* @param value
*/
public void put(String key, String value) {
InputField ipf = getInputField(key);
if (ipf != null) {
ipf.setValue(value);
} else {
this.inputfields.add(new InputField(key, value));
}
}
/**
* Gets the first inputfiled with this key. REMEMBER. There can be more than
* one file with this key
*
* @param key
* @return
*/
public InputField getInputField(String key) {
for (InputField ipf : this.inputfields) {
if (ipf.getKey() != null && ipf.getKey().equalsIgnoreCase(key)) return ipf;
}
return null;
}
/**
* Removes the first inputfiled with this key. REMEMBER. There can be more
* than one file with this key
*
* @param key
* @return
*/
public void remove(String key) {
for (InputField ipf : this.inputfields) {
if (ipf.getKey() == null && key == null) {
inputfields.remove(ipf);
return;
}
if (ipf.getKey() != null && ipf.getKey().equalsIgnoreCase(key)) {
inputfields.remove(ipf);
return;
}
}
}
/**
* Gibt den variablennamen der am besten zu varname passt zurück.
*
* @param varname
* @return
*/
public String getBestVariable(String varname) {
String best = null;
int bestDist = Integer.MAX_VALUE;
for (InputField ipf : this.inputfields) {
int dist = EditDistance.getLevenshteinDistance(varname, ipf.getKey());
if (dist < bestDist) {
best = ipf.getKey();
bestDist = dist;
}
}
return best;
}
public String toString() {
StringBuilder ret = new StringBuilder();
ret.append("Action: ");
ret.append(action);
ret.append('\n');
if (method == MethodType.POST) {
ret.append("Method: POST\n");
} else if (method == MethodType.GET) {
ret.append("Method: GET\n");
} else if (method == MethodType.PUT) {
ret.append("Method: PUT is not supported\n");
} else if (method == MethodType.UNKNOWN) {
ret.append("Method: Unknown\n");
}
for (InputField ipf : this.inputfields) {
ret.append(ipf.toString());
ret.append('\n');
}
ret.append(super.toString());
return ret.toString();
}
/**
* GIbt alle variablen als propertyString zurück
*
* @return
*/
public String getPropertyString() {
StringBuilder stbuffer = new StringBuilder();
boolean first = true;
for (InputField ipf : this.inputfields) {
/* nameless key-value are not being sent, see firefox */
if (ipf.getKey() == null) continue;
if (first) {
first = false;
} else {
stbuffer.append("&");
}
stbuffer.append(ipf.getKey());
stbuffer.append("=");
stbuffer.append(ipf.getValue());
}
return stbuffer.toString();
}
public ArrayList<InputField> getInputFieldsByType(String type) {
ArrayList<InputField> ret = new ArrayList<InputField>();
for (InputField ipf : this.inputfields) {
if (ipf.getType() != null && Regex.matches(ipf.getType(), type)) {
ret.add(ipf);
}
}
return ret;
}
/**
* Gibt ein RegexObject bezüglich des Form htmltextes zurück
*
* @param compile
* @return
*/
public Regex getRegex(String string) {
return new Regex(htmlcode, string);
}
/**
* Gibt ein RegexObject bezüglich des Form htmltextes zurück
*
* @param compile
* @return
*/
public Regex getRegex(Pattern compile) {
return new Regex(htmlcode, compile);
}
/**
* Gibt zurück ob der gesuchte needle String im html Text bgefunden wurde
*
* @param fileNotFound
* @return
*/
public boolean containsHTML(String needle) {
return new Regex(htmlcode, needle).matches();
}
public HashMap<String, String> getVarsMap() {
HashMap<String, String> ret = new HashMap<String, String>();
for (InputField ipf : this.inputfields) {
/* nameless key-value are not being sent, see firefox */
if (ipf.getKey() == null) continue;
ret.put(ipf.getKey(), ipf.getValue());
}
return ret;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public String getEncoding() {
return encoding;
}
public InputField getInputFieldByName(String name) {
for (InputField ipf : this.inputfields) {
if (ipf.getKey() != null && ipf.getKey().equalsIgnoreCase(name)) return ipf;
}
return null;
}
public InputField getInputFieldByProperty(String key) {
for (InputField ipf : this.inputfields) {
if (ipf.getStringProperty(key) != null && ipf.getStringProperty(key).equalsIgnoreCase(key)) return ipf;
}
return null;
}
public InputField getPreferredSubmit() {
return preferredSubmit;
}
/**
* Us the i-th submit field when submitted
*
* @param i
*/
public void setPreferredSubmit(int i) {
this.preferredSubmit = null;
for (InputField ipf : this.inputfields) {
if (ipf.getType() != null && ipf.getValue() != null && ipf.getType().equalsIgnoreCase("submit") && i-- <= 0) {
this.preferredSubmit = ipf;
return;
}
}
throw new IllegalArgumentException("No such Submitfield: " + i);
}
/**
* Tell the form which submit field to use
*
* @param preferredSubmit
*/
public void setPreferredSubmit(String preferredSubmit) {
this.preferredSubmit = null;
for (InputField ipf : this.inputfields) {
if (ipf.getType() != null && ipf.getValue() != null && ipf.getType().equalsIgnoreCase("submit") && ipf.getValue().equalsIgnoreCase(preferredSubmit)) {
this.preferredSubmit = ipf;
return;
}
}
logger.warning("No exact match for submit found! Trying to find best match now!");
for (InputField ipf : this.inputfields) {
if (ipf.getType() != null && ipf.getValue() != null && ipf.getType().equalsIgnoreCase("submit") && ipf.getValue().contains(preferredSubmit)) {
this.preferredSubmit = ipf;
return;
}
}
throw new IllegalArgumentException("No such Submitfield: " + preferredSubmit);
}
public InputField getInputFieldByType(String type) {
for (InputField ipf : this.inputfields) {
if (ipf.getType() != null && ipf.getType().equalsIgnoreCase(type)) return ipf;
}
return null;
}
public boolean hasInputFieldByName(String name) {
return this.getInputFieldByName(name) != null;
}
/**
* Returns a list of requestvariables
*
* @return
*/
public ArrayList<RequestVariable> getRequestVariables() {
ArrayList<RequestVariable> ret = new ArrayList<RequestVariable>();
for (InputField ipf : this.inputfields) {
// Do not send not prefered Submit types
if (this.getPreferredSubmit() != null && ipf.getType() != null && ipf.getType().equalsIgnoreCase("submit") && getPreferredSubmit() != ipf) continue;
if (ipf.getKey() == null) continue;/*
* nameless key-value are not
* being sent, see firefox
*/
if (ipf.getValue() == null) continue;
if (ipf.getType() != null && ipf.getType().equalsIgnoreCase("image")) {
ret.add(new RequestVariable(ipf.getKey() + ".x", new Random().nextInt(100) + ""));
ret.add(new RequestVariable(ipf.getKey() + ".y", new Random().nextInt(100) + ""));
} else {
ret.add(new RequestVariable(ipf.getKey(), ipf.getValue()));
}
}
return ret;
}
}

View File

@ -1,460 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.parser.html;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jd.controlling.JDLogger;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.parser.Regex;
public class HTMLParser {
/**
* Diese Methode sucht nach passwörtern in einem Datensatz
*
* @param data
* @return
*/
public static ArrayList<String> findPasswords(String data) {
if (data == null) { return new ArrayList<String>(); }
ArrayList<String> ret = new ArrayList<String>();
data = data.replaceAll("(?s)<!-- .*? -->", "").replaceAll("(?s)<script .*?>.*?</script>", "").replaceAll("(?s)<.*?>", "").replaceAll("Spoiler:", "").replaceAll("(no.{0,2}|kein.{0,8}|ohne.{0,8}|nicht.{0,8})(pw|passwort|password|pass)", "").replaceAll("(pw|passwort|password|pass).{0,12}(nicht|falsch|wrong)", "");
Pattern pattern = Pattern.compile("(пароль|пасс|pa?s?w|passwort|password|passw?)[\\s][\\s]*?[\"']([[^\\:\"'\\s]][^\"'\\s]*)[\"']?", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(data);
while (matcher.find()) {
String pass = matcher.group(2);
if (pass != null && pass.length() > 2 && !pass.matches(".*(rar|zip|jpg|gif|png|html|php|avi|mpg)$") && !ret.contains(pass)) {
ret.add(pass);
}
}
pattern = Pattern.compile("(пароль|пасс|pa?s?w|passwort|password|passw?)[\\s][\\s]*?([[^\\:\"'\\s]][^\"'\\s]*)[\\s]?", Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(data);
while (matcher.find()) {
String pass = matcher.group(2);
if (pass != null && pass.length() > 4 && !pass.matches(".*(rar|zip|jpg|gif|png|html|php|avi|mpg)$") && !ret.contains(pass)) {
ret.add(pass);
}
}
pattern = Pattern.compile("(пароль|пасс|pa?s?w|passwort|password|passw?)[\\s]?(\\:|=)[\\s]*?[\"']([^\"']+)[\"']?", Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(data);
while (matcher.find()) {
String pass = matcher.group(2);
if (pass != null && pass.length() > 2 && !pass.matches(".*(rar|zip|jpg|gif|png|html|php|avi|mpg)$") && !ret.contains(pass)) {
ret.add(pass);
}
}
pattern = Pattern.compile("(пароль|пасс|pa?s?w|passwort|password|passw?)[\\s]?(\\:|=[\\s]*?)([^\"'\\s]+)[\\s]?", Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(data);
while (matcher.find()) {
String pass = matcher.group(3);
if (pass != null && pass.length() > 2 && !pass.matches(".*(rar|zip|jpg|gif|png|html|php|avi|mpg)$") && !ret.contains(pass)) {
ret.add(pass);
}
}
return ret;
}
/**
* Diese Methode sucht die vordefinierten input type="hidden" und formatiert
* sie zu einem poststring z.b. würde bei:
*
* <input type="hidden" name="f" value="f50b0f" /> <input type="hidden"
* name="h" value="390b4be0182b85b0" /> <input type="hidden" name="b"
* value="9" />
*
* f=f50b0f&h=390b4be0182b85b0&b=9 ausgegeben werden
*
* @param data
* Der zu durchsuchende Text
*
* @return ein String, der als POST Parameter genutzt werden kann und alle
* Parameter des Formulars enthält
*/
public static String getFormInputHidden(String data) {
return HTMLParser.joinMap(HTMLParser.getInputHiddenFields(data), "=", "&");
}
/**
* Diese Methode sucht die vordefinierten input type="hidden" zwischen
* startpattern und lastpattern und formatiert sie zu einem poststring z.b.
* würde bei:
*
* <input type="hidden" name="f" value="f50b0f" /> <input type="hidden"
* name="h" value="390b4be0182b85b0" /> <input type="hidden" name="b"
* value="9" />
*
* f=f50b0f&h=390b4be0182b85b0&b=9 rauskommen
*
* @param data
* Der zu durchsuchende Text
* @param startPattern
* der Pattern, bei dem die Suche beginnt
* @param lastPattern
* der Pattern, bei dem die Suche endet
* @return ein String, der als POST Parameter genutzt werden kann und alle
* Parameter des Formulars enthält
*/
public static String getFormInputHidden(String data, String startPattern, String lastPattern) {
String pat = new Regex(data, startPattern + "(.*?)" + lastPattern).getMatch(0);
if (pat == null) { return null; }
return HTMLParser.getFormInputHidden(pat);
}
/**
* Gibt alle links die in data gefunden wurden als Stringliste zurück
*
* @param data
* @return STringliste
*/
public static String getHttpLinkList(String data) {
String[] links = HTMLParser.getHttpLinks(data, null);
return ArrayToString(links);
}
/**
* converts a String array into a string which is parsable by
* getHttpLinksIntern
*/
private static String ArrayToString(String[] links) {
if (links == null || links.length == 0) return "";
StringBuilder ret = new StringBuilder();
char tmp[] = new char[] { '"', '\r', '\n' };
for (String element : links) {
ret.append('\"');
ret.append(element.trim());
ret.append(tmp);
}
return ret.toString();
}
public static String[] getHttpLinks(String data, String url) {
String[] links = getHttpLinksIntern(data, url);
if (links == null || links.length == 0) return links;
/*
* in case we have valid and invalid (...) urls for the same link, we
* only use the valid one
*/
ArrayList<String> tmplinks = new ArrayList<String>();
for (String link : links) {
if (link.contains("...")) {
String check = link.substring(0, link.indexOf("..."));
String found = link;
for (String link2 : links) {
if (link2.startsWith(check) && !link2.contains("...")) {
found = link2;
break;
}
}
if (!tmplinks.contains(found)) tmplinks.add(found);
} else {
tmplinks.add(link);
}
}
return tmplinks.toArray(new String[tmplinks.size()]);
}
/**
* Sucht alle Links heraus
*
* @param data
* ist der Quelltext einer Html-Datei
* @param url
* der Link von dem der Quelltext stammt (um die base automatisch
* zu setzen)
* @return Linkliste aus data extrahiert
*/
public static String[] getHttpLinksIntern(String data, String url) {
data = data.trim();
/*
* replace urlencoded br tags, so we can find all links seperated by
* those
*/
data = data.replaceAll("%3Cbr%20/%3E", "<br />");
/* place all replaces here that seperates links */
/* replace <br> tags with space so we we can seperate the links */
data = data.replaceAll("<br>", " ");
/*
* remove all span because they can break url parsing (eg when
* google-code-prettify is used)
*/
// not needed here because our filter below will take care of them
// data = data.replaceAll("(?i)<span.*?>", "");
// data = data.replaceAll("(?i)</span.*?>", "");
/* CHECKME: why remove url/link tags? */
data = data.replaceAll("(?s)\\[(url|link)\\].*?\\[/(url|link)\\]", "");
/* filtering tags, recursion command me ;) */
while (true) {
String nexttag = new Regex(data, "<(.*?)>").getMatch(0);
if (nexttag == null) {
/* no further tag found, lets continue */
break;
} else {
/* lets check if tag contains links */
String[] result = getHttpLinksIntern(nexttag, url);
if (result.length == 0) {
if (nexttag.startsWith("/div")) {
/* <div>, insert newline here */
data = data.replaceFirst("(?s)<.*?>", "\r\n");
} else {
/* no links, lets replace it with nothing */
data = data.replaceFirst("(?s)<.*?>", "");
}
} else {
/* lets replace the tag with the links */
data = data.replaceFirst("(?s)<.*?>", ArrayToString(result));
}
}
}
String protocolPattern = "(flashget|h.{2,3}|directhttp|httpviajd|httpsviajd|https|ccf|dlc|ftp|jd|rsdf|jdlist)";
if (!data.matches(".*<.*>.*")) {
int c = new Regex(data, "(" + protocolPattern + "://|(?<!://)www\\.)").count();
if (c == 0)
return new String[] {};
else if (c == 1 && data.length() < 100 && data.matches("^(" + protocolPattern + "://|www\\.).*")) {
String link = data.replaceFirst("h.{2,3}://", "http://").replaceFirst("^www\\.", "http://www.").replaceFirst("[<>\"].*", "");
URLConnectionAdapter con = null;
try {
if (!link.matches(".*\\s.*") || (con = new Browser().openGetConnection(link.replaceFirst("^httpviajd", "http").replaceAll("\\s", "%20"))).isOK()) {
if (con != null) con.disconnect();
return new String[] { link.replaceAll("\\s", "%20") };
}
} catch (Exception e) {
// TODO Auto-generated catch block
JDLogger.exception(e);
}
if (con != null) con.disconnect();
}
}
url = url == null ? "" : url;
Matcher m;
String link;
String basename = "";
String host = "";
LinkedList<String> set = new LinkedList<String>();
Pattern[] basePattern = new Pattern[] { Pattern.compile("(?s)<[ ]?base[^>]*?href=('|\")(.*?)\\1", Pattern.CASE_INSENSITIVE), Pattern.compile("(?s)<[ ]?base[^>]*?(href)=([^'\"][^\\s]*)", Pattern.CASE_INSENSITIVE) };
for (Pattern element : basePattern) {
m = element.matcher(data);
if (m.find()) {
url = m.group(2);
break;
}
}
String pro = "http";
if (url != null && url.trim().length() > 0) {
if (url.startsWith("directhttp://")) {
pro = "directhttp";
}
if (url.startsWith("https://")) {
pro = "https";
}
if (url.startsWith("jd://")) {
pro = "jd";
}
if (url.startsWith("rsdf://")) {
pro = "rsdf";
}
if (url.startsWith("ccf://")) {
pro = "ccf";
}
if (url.startsWith("dlc://")) {
pro = "dlc";
}
if (url.startsWith("jdlist://")) {
pro = "jdlist";
}
if (url.startsWith("ftp://")) {
pro = "ftp";
}
if (url.startsWith("flashget://")) {
pro = "flashget";
}
url = url.replace(pro + "://", "");
int dot = url.lastIndexOf('/');
if (dot != -1) {
basename = pro + "://" + url.substring(0, dot + 1);
} else {
basename = pro + "://" + url + "/";
}
dot = url.indexOf('/');
if (dot != -1) {
host = pro + "://" + url.substring(0, dot);
} else {
host = pro + "://" + url;
}
url = pro + "://" + url;
} else {
url = "";
}
final class Httppattern {
public Pattern p;
public int group;
public Httppattern(Pattern p, int group) {
this.p = p;
this.group = group;
}
}
Httppattern[] linkAndFormPattern = new Httppattern[] { new Httppattern(Pattern.compile("src.*?=.*?['|\"](.*?)['|\"]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL), 1), new Httppattern(Pattern.compile("src.*?=(.*?)[ |>]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL), 1), new Httppattern(Pattern.compile("(<[ ]?a[^>]*?href=|<[ ]?form[^>]*?action=)('|\")(.*?)\\2", Pattern.CASE_INSENSITIVE | Pattern.DOTALL), 3), new Httppattern(Pattern.compile("(<[ ]?a[^>]*?href=|<[ ]?form[^>]*?action=)([^'\"][^\\s]*)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL), 2), new Httppattern(Pattern.compile("\\[(link|url)\\](.*?)\\[/\\1\\]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL), 2) };
for (Httppattern element : linkAndFormPattern) {
m = element.p.matcher(data);
while (m.find()) {
link = m.group(element.group);
link = link.replaceAll("h.{2,3}://", "http://");
if (!(link.length() > 3 && link.matches("^" + protocolPattern + "://.*")) && link.length() > 0) {
if (link.length() > 2 && link.startsWith("www")) {
link = pro + "://" + link;
}
if (link.charAt(0) == '/') {
link = host + link;
} else if (link.charAt(0) == '#') {
link = url + link;
} else {
link = basename + link;
}
}
link = link.trim();
try {
new URL(link);
if (!set.contains(link)) {
set.add(link);
}
} catch (MalformedURLException e) {
}
}
}
m = Pattern.compile("(" + protocolPattern + "://|www\\.)[^\\s<>'\"]*(((?!\\s" + protocolPattern + "://|\\swww\\.)[^<>'\"]){0,20}([\\?|\\&][^<>'\\s\"]{1,10}\\=[^<>'\\s\"]+|\\.(htm[^<>'\\s\"]*|php|cgi|rar|zip|exe|avi|mpe?g|7z|bz2|doc|jpg|bmp|m4a|mdf|mkv|wav|mp[34]|pdf|wm[^<>'\\s\"]*|xcf|jar|swf|class|cue|bin|dll|cab|png|ico|gif|iso)[^<>'\\s\"]*))?", Pattern.CASE_INSENSITIVE).matcher(data);
while (m.find()) {
link = m.group(0);
link = link.replaceAll("^h.{2,3}://", "http://");
link = link.replaceFirst("^www\\.", "http://www\\.");
link = link.trim();
if (!set.contains(link)) {
set.add(link);
}
}
return set.toArray(new String[set.size()]);
}
/**
* Gibt alle Hidden fields als hasMap zurück
*
* @param data
* @return hasmap mit allen hidden fields variablen
*/
public static HashMap<String, String> getInputHiddenFields(String data) {
Pattern intput1 = Pattern.compile("(?s)<[ ]?input([^>]*?type=['\"]?hidden['\"]?[^>]*?)[/]?>", Pattern.CASE_INSENSITIVE);
Pattern intput2 = Pattern.compile("name=['\"]([^'\"]*?)['\"]", Pattern.CASE_INSENSITIVE);
Pattern intput3 = Pattern.compile("value=['\"]([^'\"]*?)['\"]", Pattern.CASE_INSENSITIVE);
Pattern intput4 = Pattern.compile("name=([^\\s]*)", Pattern.CASE_INSENSITIVE);
Pattern intput5 = Pattern.compile("value=([^\\s]*)", Pattern.CASE_INSENSITIVE);
Matcher matcher1 = intput1.matcher(data);
Matcher matcher2;
Matcher matcher3;
Matcher matcher4;
Matcher matcher5;
HashMap<String, String> ret = new HashMap<String, String>();
boolean iscompl;
while (matcher1.find()) {
matcher2 = intput2.matcher(matcher1.group(1) + " ");
matcher3 = intput3.matcher(matcher1.group(1) + " ");
matcher4 = intput4.matcher(matcher1.group(1) + " ");
matcher5 = intput5.matcher(matcher1.group(1) + " ");
iscompl = false;
String key, value;
key = value = null;
if (matcher2.find()) {
iscompl = true;
key = matcher2.group(1);
} else if (matcher4.find()) {
iscompl = true;
key = matcher4.group(1);
}
if (matcher3.find() && iscompl) {
value = matcher3.group(1);
} else if (matcher5.find() && iscompl) {
value = matcher5.group(1);
} else {
iscompl = false;
}
ret.put(key, value);
}
return ret;
}
/**
* Ermittelt alle hidden input felder in einem HTML Text und gibt die hidden
* variables als hashmap zurück es wird dabei nur der text zwischen start
* dun endpattern ausgewertet
*
* @param data
* @param startPattern
* @param lastPattern
* @return hashmap mit hidden input variablen zwischen startPattern und
* endPattern
*/
public static HashMap<String, String> getInputHiddenFields(String data, String startPattern, String lastPattern) {
return HTMLParser.getInputHiddenFields(new Regex(data, startPattern + "(.*?)" + lastPattern).getMatch(0));
}
/**
* @author olimex Fügt Map als String mit Trennzeichen zusammen TODO:
* auslagern
* @param map
* Map
* @param delPair
* Trennzeichen zwischen Key und Value
* @param delMap
* Trennzeichen zwischen Map-Einträgen
* @return Key-value pairs
*/
public static String joinMap(Map<String, String> map, String delPair, String delMap) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (Map.Entry<String, String> entry : map.entrySet()) {
if (first) {
first = false;
} else {
buffer.append(delMap);
}
buffer.append(entry.getKey());
buffer.append(delPair);
buffer.append(entry.getValue());
}
return buffer.toString();
}
}

View File

@ -1,127 +0,0 @@
// jDownloader - Downloadmanager
// Copyright (C) 2009 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.parser.html;
import java.io.File;
import jd.config.Property;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
public class InputField extends Property {
private static final long serialVersionUID = 7859094911920903660L;
private String key = null;
private String value = null;
private String type = null;
public InputField(String key, String value) {
this.key = key;
this.value = value;
}
public static InputField parse(String data) {
/* first we try values with " at start/end */
String[][] matches = new Regex(data, "[\"' ](\\w+?)[ ]*=[ ]*[\"](.*?)[\"]").getMatches();
if (matches == null || matches.length == 0) {
/* then we try values with ' at start/end */
matches = new Regex(data, "[\"' ](\\w+?)[ ]*=[ ]*['](.*?)[']").getMatches();
}
String[][] matches2 = new Regex(data, "[\"' ](\\w+?)[ ]*=[ ]*([^>^ ^\"^']+)").getMatches();
InputField ret = new InputField();
for (String[] match : matches) {
if (match[0].equalsIgnoreCase("type")) {
ret.setType(match[1]);
} else if (match[0].equalsIgnoreCase("name")) {
ret.setKey(Encoding.formEncoding(match[1]));
} else if (match[0].equalsIgnoreCase("value")) {
ret.setValue(Encoding.formEncoding(match[1]));
} else {
ret.setProperty(Encoding.formEncoding(match[0]), Encoding.formEncoding(match[1]));
}
}
for (String[] match : matches2) {
if (match[0].equalsIgnoreCase("type")) {
ret.setType(match[1]);
} else if (match[0].equalsIgnoreCase("name")) {
ret.setKey(Encoding.formEncoding(match[1]));
} else if (match[0].equalsIgnoreCase("value")) {
ret.setValue(Encoding.formEncoding(match[1]));
} else {
ret.setProperty(Encoding.formEncoding(match[0]), Encoding.formEncoding(match[1]));
}
}
// if (ret.getType() != null && ret.getType().equalsIgnoreCase("file"))
// {
// // method = METHOD_FILEPOST;
//
// }
return ret;
}
public String toString() {
return "Field: " + this.key + "(" + this.type + ")" + " = " + this.value + " [" + super.toString() + "]";
}
public void setFileToPost(File file) {
if (!type.equalsIgnoreCase("file")) throw new IllegalStateException("No file post field");
this.value = file.getAbsolutePath();
}
public File getFileToPost() {
if (!type.equalsIgnoreCase("file")) throw new IllegalStateException("No file post field");
return new File(this.value);
}
public String getType() {
return type;
}
public void setKey(String string) {
if (string != null) string = string.trim();
this.key = string;
}
public void setType(String string) {
if (string != null) string = string.trim();
this.type = string;
}
public String getValue() {
return value;
}
public InputField() {
// TODO Auto-generated constructor stub
}
public String getKey() {
return key;
}
public void setValue(String value) {
if (value != null) value = value.trim();
this.value = value;
}
}

View File

@ -17,29 +17,30 @@
package jd.plugins;
import jd.config.Property;
import jd.parser.Regex;
import org.appwork.utils.formatter.SizeFormatter;
public class AccountInfo extends Property {
private static final long serialVersionUID = 1825140346023286206L;
private static final long serialVersionUID = 1825140346023286206L;
private long account_validUntil = -1;
private long account_trafficLeft = -1;
private long account_trafficMax = -1;
private long account_filesNum = -1;
private long account_premiumPoints = -1;
private long account_accountBalance = -1;
private long account_usedSpace = -1;
private long account_trafficShareLeft = -1;
private boolean unlimitedTraffic = true;
private boolean account_expired = false;
private String account_status;
private long account_createTime = 0;
private long account_validUntil = -1;
private long account_trafficLeft = -1;
private long account_trafficMax = -1;
private long account_filesNum = -1;
private long account_premiumPoints = -1;
private long account_accountBalance = -1;
private long account_usedSpace = -1;
private long account_trafficShareLeft = -1;
private boolean unlimitedTraffic = true;
private boolean account_expired = false;
private String account_status;
private long account_createTime = 0;
/**
* indicator that host, account has special traffic handling, do not temp
* disable if traffic =0
*/
private boolean specialTraffic = false;
private boolean specialTraffic = false;
public long getCreateTime() {
return account_createTime;
@ -184,7 +185,7 @@ public class AccountInfo extends Property {
}
public void setTrafficLeft(final String freeTraffic) {
this.setTrafficLeft(Regex.getSize(freeTraffic));
this.setTrafficLeft(SizeFormatter.getSize(freeTraffic));
}
public void setTrafficMax(final long trafficMax) {
@ -200,7 +201,7 @@ public class AccountInfo extends Property {
}
public void setUsedSpace(final String string) {
this.setUsedSpace(Regex.getSize(string));
this.setUsedSpace(SizeFormatter.getSize(string));
}
/**

View File

@ -20,7 +20,8 @@ import java.io.File;
import java.lang.reflect.Field;
import jd.controlling.JDLogger;
import jd.nutils.Formatter;
import org.appwork.utils.formatter.StringFormatter;
public class ContainerStatus {
@ -98,7 +99,7 @@ public class ContainerStatus {
Class<? extends ContainerStatus> cl = this.getClass();
Field[] fields = cl.getDeclaredFields();
StringBuilder sb = new StringBuilder();
sb.append(Formatter.fillString(Integer.toBinaryString(status), "0", "", 32) + " <Statuscode\r\n");
sb.append(StringFormatter.fillString(Integer.toBinaryString(status), "0", "", 32) + " <Statuscode\r\n");
String latest = "";
for (Field field : fields) {
if (field.getModifiers() == 25) {
@ -108,11 +109,11 @@ public class ContainerStatus {
if (hasStatus(value)) {
if (value == latestStatus) {
latest = "latest:" + field.getName() + "\r\n";
sb.append(Formatter.fillString(Integer.toBinaryString(value), "0", "", 32) + " |" + field.getName() + "\r\n");
sb.append(StringFormatter.fillString(Integer.toBinaryString(value), "0", "", 32) + " |" + field.getName() + "\r\n");
} else {
sb.append(Formatter.fillString(Integer.toBinaryString(value), "0", "", 32) + " |" + field.getName() + "\r\n");
sb.append(StringFormatter.fillString(Integer.toBinaryString(value), "0", "", 32) + " |" + field.getName() + "\r\n");
}
}
} catch (IllegalArgumentException e) {

View File

@ -30,8 +30,6 @@ import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import org.appwork.utils.event.Eventsender;
import jd.config.Property;
import jd.controlling.DownloadController;
import jd.controlling.DownloadWatchDog;
@ -41,12 +39,14 @@ import jd.http.Browser;
import jd.nutils.JDImage;
import jd.nutils.OSDetector;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.plugins.download.DownloadInterface;
import jd.plugins.download.DownloadInterface.Chunk;
import jd.utils.JDTheme;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
import org.appwork.utils.event.Eventsender;
class DownloadLinkBroadcaster extends Eventsender<DownloadLinkListener, DownloadLinkEvent> {
@Override

View File

@ -31,6 +31,8 @@ import jd.plugins.download.DownloadInterface;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.formatter.StringFormatter;
public class LinkStatus implements Serializable {
/**
@ -494,13 +496,13 @@ public class LinkStatus implements Serializable {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append(Formatter.fillString(Integer.toBinaryString(status), "0", "", 32) + " < Statuscode\r\n");
sb.append(StringFormatter.fillString(Integer.toBinaryString(status), "0", "", 32) + " < Statuscode\r\n");
String latest = "";
for (Entry<Integer, String> entry : toStringHelper.entrySet()) {
int value = entry.getKey();
if (hasStatus(value)) {
if (value == lastestStatus) latest = "Latest: " + entry.getValue() + "\r\n";
sb.append(Formatter.fillString(Integer.toBinaryString(value), "0", "", 32)).append(" | ").append(entry.getValue()).append("\r\n");
sb.append(StringFormatter.fillString(Integer.toBinaryString(value), "0", "", 32)).append(" | ").append(entry.getValue()).append("\r\n");
}
}

View File

@ -41,10 +41,11 @@ import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.nutils.Formatter;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* Diese abstrakte Klasse steuert den Zugriff auf weitere Plugins. Alle Plugins
* müssen von dieser Klasse abgeleitet werden.

View File

@ -40,9 +40,10 @@ import jd.nutils.Formatter;
import jd.nutils.encoding.Encoding;
import jd.nutils.jobber.JDRunnable;
import jd.nutils.jobber.Jobber;
import jd.parser.Regex;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* Dies ist die Oberklasse für alle Plugins, die Links entschlüsseln können
*

View File

@ -46,11 +46,12 @@ import jd.http.Browser;
import jd.nutils.Formatter;
import jd.nutils.JDImage;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.DownloadLink.AvailableStatus;
import jd.plugins.download.DownloadInterface;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* Dies ist die Oberklasse fuer alle Plugins, die von einem Anbieter Dateien
* herunterladen koennen
@ -488,6 +489,7 @@ public abstract class PluginForHost extends Plugin implements FavIconRequestor {
transferStatus.usePremium(true);
handlePremium(downloadLink, account);
} catch (PluginException e) {
e.printStackTrace();
e.fillLinkStatus(downloadLink.getLinkStatus());
if (e.getLinkStatus() == LinkStatus.ERROR_PLUGIN_DEFECT) logger.info(JDLogger.getStackTrace(e));
logger.info(downloadLink.getLinkStatus().getLongErrorMessage());

View File

@ -35,11 +35,12 @@ import jd.http.Browser;
import jd.nutils.JDFlags;
import jd.nutils.JDHash;
import jd.nutils.io.JDIO;
import jd.parser.Regex;
import jd.utils.JDUtilities;
import jd.utils.WebUpdate;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
/**
* Dies ist die Oberklasse für alle Plugins, die Containerdateien nutzen können
*

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -28,6 +27,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "abmp3.com" }, urls = { "http://(www\\.)?abmp3\\.com/download/\\d+-.*?\\.html" }, flags = { 0 })
public class AbEmPeThreeCom extends PluginForDecrypt {

View File

@ -25,13 +25,14 @@ import jd.controlling.JDLogger;
import jd.controlling.ProgressController;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision: 13155 $", interfaceVersion = 2, names = { "anilinkz.com" }, urls = { "http://[\\w\\.]*?anilinkz\\.com/(?!get).+/.+" }, flags = { 0 })
public class AniLinkzCom extends PluginForDecrypt {

View File

@ -4,13 +4,15 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
import org.appwork.utils.formatter.SizeFormatter;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "apple.com" }, urls = { "http://[\\w\\.]*?apple\\.com/trailers/[a-zA-Z0-9_/]+/" }, flags = { 0 })
public class AppleTrailer extends PluginForDecrypt {
@ -53,7 +55,7 @@ public class AppleTrailer extends PluginForDecrypt {
/* correct url if its relative */
if (!url.startsWith("http")) url = "http://trailers.apple.com" + url;
DownloadLink dlLink = createDownloadlink(url);
if (size != null) dlLink.setDownloadSize(Regex.getSize(size));
if (size != null) dlLink.setDownloadSize(SizeFormatter.getSize(size));
dlLink.setAvailable(true);
dlLink.setProperty("customHeader", customHeaders);
decryptedLinks.add(dlLink);

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -29,6 +28,8 @@ import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "archive.org" }, urls = { "http://(www\\.)?archive\\.org/details/[A-Za-z0-9_-]+" }, flags = { 0 })
public class ArchieveOrg extends PluginForDecrypt {

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -28,6 +27,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "asapload.com" }, urls = { "http://[\\w\\.]*?asapload\\.com/info\\?id=\\d+" }, flags = { 0 })
public class AsapLoadCom extends PluginForDecrypt {

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -28,6 +27,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "beemp3.com" }, urls = { "http://(www\\.)?beemp3\\.com/download\\.php\\?file=\\d+\\&song=.+" }, flags = { 0 })
public class BeeEmPeThreeCom extends PluginForDecrypt {

View File

@ -21,12 +21,13 @@ import java.util.regex.Pattern;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "blog-xx.net" }, urls = { "http://[\\w\\.]*?blog-xx\\.net/wp/(.*?)/" }, flags = { 0 })
public class BlgXXNt extends PluginForDecrypt {

View File

@ -23,13 +23,14 @@ import java.util.regex.Pattern;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "box.net" }, urls = { "http://www\\.box\\.net/shared/(\\w+\\b(?<!\\bstatic))(/rss\\.xml|#\\w*)?" }, flags = { 0 })
public class BxNt extends PluginForDecrypt {
private static final String BASE_URL_PATTERN = "(http://www\\.box\\.net/shared/\\w+)(#\\w*)?";

View File

@ -27,7 +27,6 @@ import jd.controlling.ProgressController;
import jd.http.Browser;
import jd.http.RandomUserAgent;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.parser.html.Form;
import jd.parser.html.HTMLParser;
import jd.plugins.CryptedLink;
@ -37,6 +36,8 @@ import jd.plugins.PluginException;
import jd.plugins.PluginForDecrypt;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = {}, urls = {}, flags = {})
public class CMS extends PluginForDecrypt {
public static final String[] ANNOTATION_NAMES = new String[] { "romhood.com", "turk-crew.com", "uwarez.ws", "oxygen-warez.com", "filefox.in", "pirate-loads.com", "fettrap.com", "omega-music.com", "hardcoremetal.biz", "flashload.org", "oneload.org", "1dl.in", "oneload.org", "saugking.net", "dark-load.net", "crimeland.de", "musik.am", "spreaded.net", "relfreaks.com", "xxx-4-free.net", "porn-traffic.net", "chili-warez.net", "game-freaks.net", "sceneload.to", "epicspeedload.in", "serienfreaks.to", "serienfreaks.in", "warez-load.com", "ddl-scene.com", "ddl-base.ws", "sauggirls.com", "pornfox.in", "xflat24.com", "gamegalaxy.ws", "ddl.byte.to", "jokermovie.org", "top-hitz.com", "sound-load.com", "toxic.to", "sound-load.net", "sfulc.exofire.net/cms", "dream-team.bz/cms", "titanload.to", "gate-warez.com", "hot-porn-ddl.com", "defrap.org", "defrap.biz", "dream.loadz.biz", "ebook-hell.me" };

View File

@ -28,13 +28,13 @@ import jd.controlling.JDLogger;
import jd.controlling.ProgressController;
import jd.nutils.encoding.Base64;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import jd.utils.JDHexUtils;
import org.appwork.utils.Regex;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Scriptable;

View File

@ -24,7 +24,6 @@ import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -32,6 +31,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "chomikuj.pl" }, urls = { "http://(www\\.)?chomikuj\\.pl/.+" }, flags = { 0 })
public class ChoMikujPl extends PluginForDecrypt {

View File

@ -21,7 +21,6 @@ import java.util.LinkedHashMap;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.parser.html.Form;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
@ -29,6 +28,8 @@ import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "collectr.net" }, urls = { "http://[\\w\\.]*?collectr\\.net/(out/(\\d+/)?\\d+|links/\\w+)" }, flags = { 0 })
public class Cllctr extends PluginForDecrypt {

View File

@ -22,15 +22,15 @@ import java.util.regex.Pattern;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.FilePackage;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.decrypter.TbCm.DestinationFormat;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "clipfish.de" }, urls = { "http://[\\w\\.]*?clipfish\\.de/(.*?channel/\\d+/video/\\d+|video/\\d+(/.+)?|special/.*?/video/\\d+)" }, flags = { 0 })
public class ClpfshD extends PluginForDecrypt {

View File

@ -20,12 +20,13 @@ import java.util.ArrayList;
import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "counterstrike.de" }, urls = { "http://[\\w\\.]*?4players\\.de/\\S*/download/[0-9]+/([01]/)?index\\.html?" }, flags = { 0 })
public class CntrstrkD extends PluginForDecrypt {

View File

@ -23,7 +23,6 @@ import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
@ -33,6 +32,8 @@ import jd.plugins.PluginForHost;
import jd.plugins.hoster.DirectHTTP;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "cryptbox.cc" }, urls = { "http://[\\w\\.]*?.cryptbox\\.cc/ordner/[0-9a-zA-z]+" }, flags = { 0 })
public class CrptBxCC extends PluginForDecrypt {

View File

@ -24,7 +24,6 @@ import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
@ -33,6 +32,8 @@ import jd.plugins.PluginException;
import jd.plugins.PluginForDecrypt;
import jd.utils.JDUtilities;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "crypting.bz" }, urls = { "http://[\\w\\.]*?crypting\\.bz/\\?id=[a-zA-Z0-9]+" }, flags = { 0 })
public class CrptNgBz extends PluginForDecrypt {

View File

@ -26,7 +26,6 @@ import jd.controlling.ProgressController;
import jd.crypt.AESdecrypt;
import jd.http.URLConnectionAdapter;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.parser.html.HTMLParser;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
@ -38,6 +37,8 @@ import jd.plugins.PluginForDecrypt;
import jd.utils.JDUtilities;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "crypt-it.com" }, urls = { "(http|ccf)://[\\w\\.]*?crypt-it\\.com/(s|e|d|c)/[\\w]+" }, flags = { 0 })
public class CrpttCm extends PluginForDecrypt {

View File

@ -24,7 +24,6 @@ import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.controlling.ProgressControllerEvent;
import jd.controlling.ProgressControllerListener;
import jd.parser.Regex;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
@ -32,6 +31,8 @@ import jd.plugins.FilePackage;
import jd.plugins.PluginForDecrypt;
import jd.utils.locale.JDL;
import org.appwork.utils.Regex;
@DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "audiobeats.net" }, urls = { "http://[\\w\\.]*?audiobeats\\.net/(liveset|link|event|artist)\\?id=\\d+" }, flags = { 0 })
public class DBtsNt extends PluginForDecrypt implements ProgressControllerListener {

Some files were not shown because too many files have changed in this diff Show More