CGI to learn with me (transfer)

xiaoxiao2021-03-06  40

table of Contents

What is the CGI script?

How does the CGI script work? A simple example I can use the CGI script?

Does your server configuration allow CGI scripts? Can you program? What programming language do you use? Is your server settings correct? What if your server is not a UNIX system? Anatomy CGI script

Output header output data unit The script is delivered to the script to create a special script output

Scripts that load another text response without response processing form

Form format and form script GET and POST URL encoding problem CGI variable decoding program

Uncgi cgi-lib.pl decoding files uploaded by the input yourself to do non-anatomy head script summary

Learn CGI scripts (script)

CGI means a browser-based input, a program method that is running on a web server. CGI script allows your browser to interact with users, in order to find a noun in the database, provide you write comments Or choose a few entries from a form and get a clear answer. If you have encountered a search or search on the Web, you just use the CGI script. You may not realize that because of the big Some work is running on the server, just what you see.

As a web designer, you create a client's CGI script, the server's program is used to handle user input, and the result is returned to the user.

Here you will learn everything about the CGI script:

What is the CGI script? What does it work? What is the CGI script output? How to create a CGI script with parameters or non-parameters How to create a CGI script that returns a specified response to create a CGI script for entering a form about the CGI variable you can use in the script.

This chapter assumes that under UNIX systems.

What is the CGI script?

The CGI script simply is a program running on the web server, with a browser input trigger. This script usually likes the bridge of the database such as the database in the server and system.

Isn't the CGI script not a real script? According to your server support, they may be a compiled program or batch command file or other executable things. For the sake of simplicity, we collect them as scripts Scripts.

The CGI script is any program running on the web server. CGI means Common Gateway Interface.

The CGI script is used in the following two methods: as an action of a form or as a direct LINK in a page.

How does the CGI script work?

The CGI script has server calls, Browser-based data input. Figure 1 shows a process between the browser, server, and scripts.

Figure 1. From the browser to the server to the script to the program to remember and then come back!

This has a short schematic explanation:

A URL points to a CGI script. The URL of a CGI script can appear anywhere as a normal URL. The server receives the request, and performs scripts according to the script file pointed to by that URL (note files and extensions). Scripts Perform an operation based on input data, including the query database, calculate value, or other programs in the system. Script produces a certain web The server can understand the output. The server receives the output from the script and transmits it back to the browser, allowing the user to understand the results.

A simple example

Here, explain all the details related to the occurrence of the occurrence step by step.

figure 2:

Display Date is a connection pointing to the CGI script. Its HTML is like this:

Display the date Description is a CGI script because there is a CGI-BIN path path. In many servers CGI- BIN is the directory that can only place the CGI script.

When you choose this connection, your browser will request a request to www.popchina.com servers. The server receives this request to calculate the script file name at the URL and then execute this script.

This getDate script is implemented in the UNIX system:

#! / bin / sh

Echo Content-Type: Text / Plain

echo

/ bin / date The first line is a special command, telling the Unix system This is a shell script; the real situation is the next line starting from this line, this script is two things: it outputs line content-type: Text / Plain, Then start an empty line; second, it calls the UNIX system time Date program, which outputs the date and time. The output of the script should be like this:

Content-Type: Text / Plain

Tue Oct 25 16:15:57 EDT 1994 This content-type is Dongdong? It is a special code, the web server is used to tell the browser to output this text. This is the same as the content-type meaning in HTML.

Such a browser output is as shown in Figure 3.

This is the most basic, the actual situation is much more complicated, in short, how can you understand how the browser, server, and scripts work.

Can I use a CGI script?

Before you use the CGI script, there are two things you might want to resolve: The CGI script is a high-level web feature and requires you as good as the web server manager.

Are you definite? It's not until you do. Ok! let's continue.

Does your server configuration allow CGI scripts?

In order to write and run the CGI script, you need a web server. You don't like the usual HTML file, you can't write or trial your CGI script on your local system; you have to do this through the web server.

But even if you have a web server, this server must be specifically configured to run the CGI script. That means that all your scripts must be placed in a directory called CGI-bin.

Before writing the CGI script, ask if your server manager allows you to install and run the CGI script, and if you can, where do they have? Also, you have to have a real web server, if you are an FTP or GoPher server, then you can't use CGI.

If you are running on your own server, you must specifically create a directory called cgi-bin and configure your server to approve this directory as a script directory. You must also remember the following related CGI script features:

Each script is a program that runs on the browser to request, when executed, using CPU time and memory. What if there is a thousand these scripts running at the same time? Your system will not bear the load until it crashes. If you don't carefully write your CGI script, you will be possible to let others enter your system through your CGI script parameters.

Will you program?

Beginners pay attention! Generally, you must have some basic programming concepts and methods. You have to have similar systems work. If you don't have these backgrounds, you have to learn, ok, don't say much.

What programming language do you have to use?

You can write CGI scripts in any language you are familiar with, as long as your script follows the rules of the next section, as long as that language can run on your web server system.

In this learning manual, only two languages ​​are written in both languages: UNIX Shell and Perl language. This shell is suitable for running on any similar UNIX system and is easy to learn, but it is difficult to handle complexity. Perl, To use this language, it is free, this language is stable and powerful, similar to C, but it is also difficult to learn.

Is your server settings correct?

In order to run any CGI script, your server must be set to be able to run them without a simple or complex, your server must be placed in a specific directory, must have a file extension that relies on your server set.

If you are a rental server, you have to allow the CGI script to be run.

If you have your own server, check how your server manual processes the CGI script.

If you are not unix?

I have to find another learning manual.

Anatomy a CGI script

If you write it for a long time, overcome a lot of warnings and configurations, congratulations, you have some CGI scripts, and you can use it on your web page. In this chapter, how is the learning script is executed, what is your server? Respond with their dialogue. Output head

Although your CGI script allows you to do anything, the output of the script must still have a predetermined form.

This "script output" means that your script sends back the server's data. In the UNIX system, the output is the output of the standard output, the server detects it. In other systems and servers, your script output may be different.

This head is actually part of the text, which is the information protocol between the server and the browser. You can't see it.

There are three types of heads: Content-Type, Location, and Status. Content-Type is most common.

About Content-Type explanation You can see the description of HTML, a specific code like you can issue:

Content-Type: TEXT / HTML In this example, the type of output data is text / html; in other words, he is an HTML file.

Table 1. General Format and Content-Types.

FormatContent-typeHtmlText / HTMLTextText / PlapingIfimage / Gifjpegimage / JPEGPOSTScriptApplication / PostScriptmpegvideo / MPEG

Note that Content-Type must be followed by one blank line. If you don't have a space line, the server will not be able to figure out where this head is over.

Output Data

The data you export should comply with the content-type you specified; if Content-Type is Text / HTML, the output placed should be in HTML. If Content-Type is image / gif, the output should be in a binary GIF file.

Exercise 1: Try a small.

T This is a simple script of a simple output date. This CGI script also checks to see if I have already logged to my web server and report what I found (as in Figure 4).

This is a very simple example, he can prepare this:

is laura logged in? This is a script without input, it only runs and returns data.

According to the foregoing elaboration, this script content is this: #! / Bin / sh

Echo Content-Type: Text / HTML

echo " "

echo " is laura there? </ title>"</p> <p>Echo "</ head> <body>" In order to test whether I have already launched the system, use the who command (my login name to assure the Lemay), the stock result is in the variable ISON. If I log in, the variable ison will some content, otherwise It is empty.</p> <p>Ison = 'WHO | GREP Lemay' test results and the script that returns the corresponding prompt is this:</p> <p>IF [! -z "$ ison";.</p> <p>echo "<p> laura is logged in." </ p></p> <p>Else</p> <p>echo "<p> laura isn't logged in." </ p></p> <p>Fi finally closed HTML:</p> <p>echo "</ body> </ html>" Now you run him from the command line, test it, you will get a result that I didn't log in to your system, of course, it is impossible, his output is like this:</p> <p>Content-Type: Text / HTML</p> <p><Html> <head></p> <p><Title> Are you there? </ Title></p> <p></ HEAD> <body></p> <p><P> laura is not logged in.</p> <p></ Body> </ html> This is an HTML text that is output so that your browser will display him normally because he is an HTML file.</p> <p>Now, in the cgi-bin directory of your server, he doesn't reach the CGI-BIN directory, you must ask your server manager, you can't make it yourself to build a cgi-bin directory yourself. use.</p> <p>This example is the following script as follows:</p> <p>#! / bin / sh</p> <p>Echo "Content-Type: Text / HTML"</p> <p>echo</p> <p>echo "<html> <head>"</p> <p>echo "<title> is laura there? </ title>"</p> <p>echo "</ head> <body>"</p> <p>ISON = 'WHO | GREP LEMAY'</p> <p>IF [! -z "$ ison";.</p> <p>echo "<p> laura is logged in"</p> <p>Else</p> <p>echo "<p> laura isn't logged in"</p> <p>Fi</p> <p>echo "</ body> </ html>"</p> <p>Script with parameters</p> <p>In order to pass a parameter to the script, you can use (?) Between the URL between the scripts and parameters, indicate each single parameter with the plus sign ( ), such as:</p> <p><a href="/cgi-bin/myscript?arg1 arg24ARG3"> Run My Script </A> When the server receives this request, it passes Arg1, Arg2, and Arg3 parameters to the script. You can then be on the script Use these parameters in.</p> <p>This method sometimes called queries because it is used in the search function.</p> <p>Exercise 2: Check if someone landed.</p> <p>Since you know how to use parameters, let us continue the example of Pinglaura, by modifying this example we get this script pinggeneric.</p> <p>We take a different topic:</p> <p>#! / bin / sh</p> <p>Echo "Content-Type: Text / HTML"</p> <p>echo</p> <p>echo "<html> <head>"</p> <p>echo "<title> Are you there? </ title>"</p> <p>Echo "</ head> <body>" In the above example, the next step should be tested if I log in, here we use the parameter $ {1} instead of my name LEMAY, $ {1} as the first parameter, $ {2} As the second, $ {3} as the third.</p> <p>ISON = 'WHO | GREP "$ {1}"'</p> <p>All remaining modifications are as follows:</p> <p>IF [! -z "$ ison";.</p> <p>Echo "<p> $ 1 is logged in"</p> <p>Else</p> <p>Echo "<p> $ 1 isn't logged in"</p> <p>Fi</p> <p>Echo "</ body> </ html>" Ok, let's modify the connection in the HTML page! It turned out to be like this:</p> <p><a href="http://www.lne.com/cgi-bin/pinglaura""> is laura logged in? </A> This is the case after the universal query function, such as the query name called John to log in: <a href="http://www.lne.com/cgi-bin/pinggeneric?john"> is john logged in? </A></p> <p>Try it on your server to see if there is a result.</p> <p>Pass other information to the script</p> <p>There is a second way to pass the information to the CGI script. It is called path information Path Information as a parameter that is not changed in script calls, like a temporary file name or calling script. As you can see, The parameters behind the question mark are changed by the input of the user form. Path Information Path Info is used as other information to pass to the script, in fact, you can use it as anything.</p> <p>Path Information Path Information is a method of frequently transmitting information as usual. Path Path Information typically refers to such files such as profiles, temporary files, or scripts, such as configuration files, temporary files, or scripts.</p> <p>Look at the following path information Path Information example,:</p> <p>http: // myhost / cgi-bin / myscript / remaining_path_info? arg1 arg2 When the script is run, the information in the path will be placed on the environmental parameter PATH_INFO. You can use this information in your script content.</p> <p>For example, let us assume that you have multiple connections to the same script on multiple pages. You can use this path information to display the connected HTML file name. This way, after you complete your script, when you send When I go back to an HTML file, you can include a connection in this file, send back the user from the beginning.</p> <p>You will learn more path information in the next chapter: useful forms and scripts.</p> <p>Create a special script output</p> <p>Now you have learned the data that is generally HTML data to send to the browser, such as output data. But if you don't want to send the script results as a data stream back to the browser, try to send a page that exists back, how Do it? If you just have to do something, do something do not let any result answer to your browser, what should I do?</p> <p>You don't have to be afraid, here is here to explain these situations.</p> <p>Use another text as a response</p> <p>The CGI output is not a data stream, sometimes telling the browser to be a page on the server, in order to issue this information, look at the following example:</p> <p>Location: ../docs/final.html This Location row is used as a usual output location, that is, if you use location, you don't have to use data like Content-Type (actually, you can't ). As Content-Type, you must also follow up with an empty line behind this line.</p> <p>Point to this file can be a URL or relative path. All relative paths refer to the location of the script. The final.html text in the example is in the current directory DOCS directory:</p> <p>echo location: ../docs/final.html</p> <p>echo</p> <p>You can't use both outputs simultaneously. For example, if you want to output a standard page, you want to add the content of the customer in this page, you have to build these two parts yourself with the Content-Type. Note : You can use the script command to open a local file as the data directly.</p> <p>No response</p> <p>Sometimes there may be no output for a CGI script. Sometimes you just want to collect some information from the user. You don't have to call a new text, nor you need to output the result or open an existing file. On the browser, the screen is still .</p> <p>Fortunately, it's easy. You just want to output the following command (back with an empty line):</p> <p>Echo Status: 204 no response</p> <p>Echo This Status head provides a status code to the server (and also gives the browser). Special 204 will pass to the browser, if it can identify it, it will not do anything. Although there is no response is part of an official HTTP. But not suitable for all browsers, may have a strange result, then you have to try it more.</p> <p>Handling the script of the form</p> <p>Today, most CGI scripts are used to handle form input. This process is roughly the same, but still somewhat different, such as CGI scripts as long as they are called; how data is sent from the server to the browser.</p> <p>Remember, most forms have two parts: HTML's form format; CGI script for processing form data. This CGI script uses tag <form> attribute call.</p> <p>Form form and form script</p> <p>As mentioned above, since there are two parts of the form. As follows:</p> <p>This Action property contains scripts for processing a form:</p> <p><Form action = "http://www.popchina.com/cgi-bin/processorscript"></p> <p>In this form, each input area has an NAME attribute, used to call the form unit element. When this form data is submitted to the CGI script defined in the action, these Name and the input content are used as a number or character. Pass to the script.</p> <p>GET and POST</p> <p>The form has two methods from the browser to the server. GET and POST.</p> <p>The method of our discussion is actually GET, which puts the data packaging in the environment variable query_string as part of the entire overall as the URL to the server.</p> <p>POST is a lot similar to get the same thing. Different places are that it is separated to deliver data to the script. Your script gets these data through standard input. (Some web servers are stored in temporary files.) This query_string environment variable will not Set.</p> <p>Then do you use that way? POST is a safe way, especially if there are many data in your form. When you use get, this server assigns all the form data, but this variable can be stored limited In other words, if you have a lot of data but you will lose a lot of data.</p> <p>If you use POST, you can use data as much as possible because these data never assigned to a variable.</p> <p>URL encoding</p> <p>URL encoding is a browser to package form input format. The browser gets all Name and the value from the form, which will be encoded as the Name / Value parameter, remove the characters that cannot be transmitted, etc., etc. These depends on whether you use GET or POST? As part of the URL or separated to the server. No matter which case, in the form input format of the server side is like this:</p> <p>Thename = Ichabod Crane & Gernder = MALE & Status = missing & headless = YESURL encoding follows the following rules:</p> <p>Each pair name is separated by the & symbol. Each pair name / value from the form is separated by = characters. If the user does not enter the value to this Name, then this Name still appears, but does not value (like "Name =" like this). Any special characters (that is, those who are not simple, seven ASCIIs, such as Chinese characters) will be coded with percentage%. Of course, like =, &, and% of these special characters. In the input area The space will be displayed in the plus . Because the form input is passed to your script with this URL encoding, you must decode before you use these parameters, because decoding is a very common job, you can do this work. You don't have It is necessary to write this decoder yourself.</p> <p>Here is a decoding program called Uncgi, you can</p> <p>http://www.hyperion.com/~koreth/uncgi.html. Get the original code, installed in your own CGI-BIN directory.</p> <p>Practice 3: Tell me your name.</p> <p>Let us explain in this example, as shown in Figure 5. This input is sent to the script, then send it back to the information displaying a Hello (see Figure 6).</p> <p>What if you don't enter any stuff at the name input? See Figure 7.</p> <p>Modifying the form of HTML now we will give a real example:</p> <p><Form method = post action = "../ cgi-bin / form-name></p> <p></ Form> If you decode from the Input in the Input in Uncgi, the situation is a bit different. In order to be working properly, you must first call UNCGI, if UNCGI is a directory, plus the actual script name, like this:</p> <p><Form method = post action = "../ cgi-bin / subggi / form-name"></p> <p></ Form></p> <p>This way, you don't have to modify the original HTML in the form; the original HTML can work very well.</p> <p>script</p> <p>Processing forms Enter is a CGI script, let's take a closer look.</p> <p>The first step in the script is to decode. In this example, we have used UNCGI to decode input data. The actual form has been decoded for you. By establishing a UNCGI directory, the server will automatically decode This, all Name / Value is ready to wait for your use.</p> <p>Now, one example begins partial assumptions:</p> <p>Echo Content-Type: Text / HTML</p> <p>echo</p> <p>echo "<html> <head>"</p> <p>echo "<title> Hello </ Title>"</p> <p>echo "</ head> <body>"</p> <p>Echo "<p>" Next, there are two cases to handle: one is the case where the user does not enter the name, one is if the input is to say hello.</p> <p>The value of this Name element is included in the www_thename environment variable. With a simple test command (-Z), you can view the environment variable is empty or include the corresponding output value:</p> <p>IF [! -z "$ www_thename];.";</p> <p>echo "Hello,"</p> <p>Echo $ www_thename</p> <p>Else</p> <p>echo "you don't have a name?"</p> <p>Fi finally adds a connection "Go Back". Used to return:</p> <p>Echo "</ p> <p> <a href="../lemay/name1.html"> Go back </a> </ p>"</p> <p>echo "</ body> </ html>"</p> <p>problem</p> <p>Here is a common problem using CGI scripts:</p> <p>The script content is only displayed. You correctly configure your server to run the CGI script? Is your script in the cgi-bin directory? Is this this extension of your script file name if your server allows a .cgi extension CGI? ERROR 500: Server Doesn't Support Post. Solution is as the above, then you can perform your CGI with the command line, can you run normal? Is there a mistake? Document Contains No Data. Make sure your head line and data unit have a empty line. Error 500: Bad script request. Make sure your script is executable (in Unix, with chmod x your script .cgi) . Before running from the browser, you should run your script from the command line. If the client is Win95, you can log in to your server with Telnet, execute the command line, of course, you must understand the unix command .cgi variable</p> <p>Table 2 summarizes those environment variables.</p> <p>Table 2. CGI environment variables.</p> <p>Environment Variable Signs Server_namecgi Script Running Host Name and IP Address. Server_software The type of server is: CERN / 3.0 or NCSA / 1.3.gateway version of the CGI version. For UNIX Server, this is the HTTP running of the CGI / 1.1.Server_Protocol server Agreement. Here is the TCP port of the http / 1.0.server_port server, usually the web server is 80.Request_methodPost or get, depending on how your form is submitted. HTTP_ACCEPT browser can directly receive Content-Types, you can have HTTP Accept header defines. HTTP_USER_AGENT The name, version, and other platform sexual information of the browser that submits the form. HTTP_REFERER Spend the URL of the text of the form, not all browsers issued this information, do not rely on its path_info attached path information, the browser issues. Path_Translated path information specified in Path_Info. Script_name points to this CGI script The path is a (e.2,, /cgi-bin/thescript ).Query_String script parameter or form entry (if you are submitted with Get). Query_string contains the parameters behind the URL .Remote_host submit the host name of the script This value cannot be set .Remote_addr The host IP address of the script .Remote_user submits the username of the script. If the server's Authentication is activated, this value can be set. Remote_ident If the web server is running in Ident (a confirmation user connection to your protocol), the system that is submitted to the form is also running Ident. This variable contains IDENT return value. Content_type If the form is submitted with POST, this value will be Application / X-WWW-form-urlencoded. In the form of upload file, Content-Type is Multipart / Form-Data.Content_length for the number of bytes that the standard input port is submitted by POST.</p> <p>Form input decoding program</p> <p>There are currently two programs: Uncgi, and cgi-lib.pl, which is a Perl library for Perl library, and CGI-LIB.PL.</p> <p>Of course, there are programs that can decode when the form is uploaded, very few.</p> <p>Uncgi</p> <p>Note that the original code can be from</p> <p>Http://www.hyperion.com/~koreth/uncgi.html is obtained.</p> <p>CGI-LIB.PL</p> <p>This is written by Steve Brenner to help you manage the input. He can get the input from GET and POST and place it in a Perl list or array. Update version can handle files from the form. From here you can get information and original code</p> <p>Http://www.bio.cam.ac.uk/cgi-lib. If you decide to handle your form input with Perl language, cgi-lib is a good library. In order to use CGI-LIB.PL, you usually want Write this way: #! / usr / lib / perl</p> <p>Require 'CGI-LIB.PL'; CGI-LIB Although there are many subroutines, the most important thing is the readparse subtelife. Readparse reads the Name / Value in a Perl array. In your perl script Usually called:</p> <p>& Readparse (* in); In this case, the array name is IN, which can be named casually.</p> <p>After the form is decoded, you can read and process this name / value, the method is like this:</p> <p>Print $ in {'thename'}; This will display the name name is the value of the thename.</p> <p>If you have multiple Name pairs with the same name, cgi-lib.pl is separated by multiple names with (/ 0). This can properly handle your script.</p> <p>Decoding uploaded file input</p> <p>The form-based file upload requires different form inputs, and some programs can decode them.</p> <p>CGI-LIB.PL later versions can be well supported, in http://www.bio.cam.ac.uk/cgi-lib/ understand more.</p> <p>Another CGI address written in Perl is</p> <p>Http://valine.ncsa.uiuc.edu/cgi_docs.html.</p> <p>do it yourself</p> <p>Looking for special book learning:</p> <p>ftp://ds.internic.net/rfc/rfc1867.txt.</p> <p>Unattable script head</p> <p>In accordance with this book, most of the cases can be operated normally, in some cases, you can read the manual understanding.</p> <p><Isindex> script</p> <p>In order to complete the discussion group in the CGI, we look at the search of <isindex>. This is an early way to send a search keyword to the server in the browser, see the previous information.</p> <p>to sum up</p> <p>CGI scripts, sometimes called server-side scripts or gateway scripts. There are a lot of free resources on the Internet, you can search for download and read them, of course, if you are determined to translate them (maybe more understanding). This is two.</p> <p>Note: The above program can be edited by Ultra Edit, pay attention to the Unix format, must use the UNIX format store, then upload, log in with Telnet, type perl sample.pl, see if there is a bug, and call it in the browser. The CGI program includes a directory to place the CGI must change the properties 777. The HTML file to be written should also be changed to 777.</p> <p>There are now many free CGIs on the Internet. Basically meet the general needs, please query the CGI you want: http://www.itm.com/cgicolection/</p> <p>This entry illustrates free copies, but please do not delete the board bridge, I spent some time on it, you and I have a need :-).</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-65692.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="65692" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.042</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'IqlpZXOXsIPS7o3fD_2BJkTGZIjbCL4xvgm1Xnh_2BLP1VoTd8PJD9VOk4gXXb2V4kVmfLTq9QBHhigGcGWE6NdJEA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>