Write and set the copyright Handling Method

Source: Internet
Author: User
  • Create a project named 'pictures' under % SystemRoot % \ Inetpub \ wwwroot. In the Privilege Escalation command, run the following command:
    MD % systemdrive % \ Inetpub \ wwwroot \ pictures
  • Upload some digital images (this gradually resolves false images as JPG files) to the new pictures category. If you do not have any JPG file, use the following picture: http://wallpaper.iis7.org/gallery/iis7-highlight.jpg
    Note:Because of the high Internet Explorer security set on Windows Server 2008, you may see a security peer saying that the website has been blocked. To remove the IIS 7.0 background color scheme, add wallpaper.iis7.org to the trusted website.
  • Use the appcmd command column tool to create an application
    % Windir % \ system32 \ inetsrv \ appcmd add app-site. Name: "Default web site"
    -Path:/pictures-physicalpath: % systemdrive % \ Inetpub \ wwwroot \ pictures
  • Create an app_code object under the pictures category:
    MD % systemdrive % \ Inetpub \ wwwroot \ pictures \ app_code
  • Open a [Notebook] and upload the following programs to it.

    Using system;
    Using system. Web;
    Using system. drawing;
    Using system. Drawing. imaging;

    Namespace iis7demos
    {
    Public class imagecopyrighthandler: ihttphandler
    {
    Public void processrequest (httpcontext context)
    {
    String message = "copyright & copy; IIS 7.0 team ";
    Try {
    String languageheader;
    Languageheader = context. Request. headers ["Accept-language"]. substring (). toupper ();
    Switch (languageheader)
    {
    Case ("de "):
    Message = "IIS 7.0 team-alle Rechte vorbehalten ";
    Break;
    Case ("es "):
    Message = "Marca registrada IIS 7.0 team ";
    Break;
    Default:
    Break;
    }
    }
    Catch
    {
    // If something fails, e.g. No language-accept header, we go with the English message
    }
    Insertcopyrightmessage (context,
    Message,
    "Yellow"
    );
    }
    Void insertcopyrightmessage (
    Httpcontext context,
    String message,
    String color
    )
    {
    Try
    {
    // Get physical path of request
    String strpath = context. Request. physicalpath;
    // Load as bitmap
    Bitmap jpgfile = new Bitmap (strpath );
    // Add copyright message
    Graphics G = graphics. fromimage (jpgfile );
    Font F = new font ("Arial", 20, graphicsunit. pixel );
    Solidbrush sb = new solidbrush (color. fromname (color ));
    // Write copyright message to bitmap
    G. drawstring (message,
    F,
    SB,
    5,
    Jpgfile. Height-F. Height-5
    );
    F. Dispose ();
    G. Dispose ();

    // Save it to response stream
    Jpgfile. Save (context. response. outputstream,
    System. Drawing. imaging. imageformat. JPEG
    );
    Jpgfile. Dispose ();
    }
    Catch (exception E)
    {
    Context. response. Write (E. Message );
    }
    }

    Public bool isreusable
    {
    Get {return true ;}
    }
    }
    }


    Save the file as % systemdrive % \ Inetpub \ wwwroot \ pictures \ app_code \ imagecopyrighthandler. CS

  • Create a regular expression. When a JPG file is required, upload the program:
    % Windir % \ system32 \ inetsrv \ appcmd set config/section: system. Web. Server/handlers
    /+ [Name = 'imagecopyrighthandler-integrated ', Path =' *. jpg ',
    Verb = 'get, head', type = 'is7demos. imagecopyrighthandler', precondition = 'integratemode']
  • We also need to use the object logging function because there are currently no preset files:
    % Windir % \ system32 \ inetsrv \ appcmd set config "Default web site/pictures"
    -Section: directorybrowse-enabled: True
  • In the Internet Explorer Address column, add the following addresses to your application: http: // localhost/picures. Click the JPG file in IIS 7.0. You should see a jpg image with the right to write your work.
  • View the program logs. You can see that the title of "Accept-language" sent by the copyright reader is different. If you are installing Microsoft Server 2008 of the German version, the copyright will be "IIS 7.0 team-alle Rechte vorbehalten"; if you are installing the Spanish version, this is "Marca registrada IIS 7.0 team ". For all other statements, the copyright interest will be "Copyright IIS 7.0 team ". One way to upgrade this program is to change the "Accept-language" header sent by Internet Explorer:
    1. open [Internet Explorer].
    2. open the [tools] menu and click [Network Selection].
    3. click [statement] and then click "statement.
    4. click [add...]. Press train and add "es" for Spanish and "de" for German ".
    5. use the [Move Up] statement to move the new statement to the ticket client.
    6. upload streams to http: // localhost/pictures/%3cyour_jpg_file%3e.jpg. The copyright interest has changed to the statement you have set.
    7. do not forget to go back to the [Speaker] to reset the speaker. Otherwise, the Spanish or German website may be available.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.