Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
 lŽŒYÊŒã@sOdZdZddlmZmZmZddlmZddlZddl Z ddl Z ddl m Z ddlmZddlmZddlZddlZddlZd d d d d dddddddddgZdadadd„Zdd„Zdd„Zdd„Zeadade jddd d „Zddd!d „Z ddd"d „Z!d#d„Z"d$d%„Z#d&d„Z$Gd'd „d ƒZ%Gd(d „d ƒZ&e jd)d*„Z'ddddd+d„Z(e jd,d„Z)d-d„Z*d.d„Z+d/d„Z,d0d„Z-dd1d„Z.d2d3„Z/e0d4krKe'ƒdS)5z�Support module for CGI (Common Gateway Interface) scripts. This module defines a number of utilities for use by CGI scripts written in Python. z2.6é)ÚStringIOÚBytesIOÚ TextIOWrapper)ÚMappingN)Ú FeedParser)ÚMessage)ÚwarnÚMiniFieldStorageÚ FieldStorageÚparseÚparse_qsÚ parse_qslÚparse_multipartÚ parse_headerÚprint_exceptionÚ print_environÚ print_formÚprint_directoryÚprint_argumentsÚprint_environ_usageÚescapeÚc GsXtr5t r5yttdƒaWntk r4YnXtsDtantat|ŒdS)a„Write a log message, if there is a log file. Even though this function is called initlog(), you should always use log(); log is a variable that is set either to initlog (initially), to dolog (once the log file has been opened), or to nolog (when logging is disabled). The first argument is a format string; the remaining arguments (if any) are arguments to the % operator, so e.g. log("%s: %s", "a", "b") will write "a: b" to the log file, followed by a newline. If the global logfp is not None, it should be a file object to which log data is written. If the global logfp is None, the global logfile may be a string giving a filename to open, in append mode. This file should be world writable!!! If the file can't be opened, logging is silently disabled (since there is no safe place where we could send an error message). ÚaN)ÚlogfileÚlogfpÚopenÚOSErrorÚnologÚlogÚdolog)Úallargs©r!ú"/opt/python35/lib/python3.5/cgi.pyÚinitlog:s   r#cGstj||dƒdS)z=Write a log message to the log file. See initlog() for docs.Ú N)rÚwrite)ÚfmtÚargsr!r!r"r]srcGsdS)z9Dummy function, assigned to log when logging is disabled.Nr!)r r!r!r"rasrcCs&datrtjƒdatadS)zClose the log file.rN)rrÚcloser#rr!r!r!r"Úcloseloges  r)c CsÔ|dkrtj}t|dƒr0|j}nd}t|tƒrN|j}d|krdd|d<|ddkrlt|dƒ\}}|dkr£t||ƒS|d krøt |d ƒ}t rÝ|t krÝt d ƒ‚|j |ƒj |ƒ}nd }d |kr+|r|d}||d }n4tjdd…r_|rN|d}|tjd}||d r r )rFrArBr!r!r"r ½s cCs&tdtdƒtjj|||ƒS)z)Parse a query given as a string argument.z?cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl insteadrG)rrHr>r r )rFrArBr!r!r"r Ãs c Cs“ddl}d}d|kr(|d}t|ƒsGtd|fƒ‚d|}d|d}i}d}x!||krŽd}d} |r|jj|ƒ} | jdƒ} | rØyt| ƒ}Wntk r×YnX|dkrtr|tkrtd ƒ‚|j|ƒ} nd} g} xX|j ƒ} | s<|}P| j dƒrj| j ƒ}|||fkrjP| j | ƒq#W| dkrŠqn|dkr| r| d} | dd…d krÏ| dd…} n&| dd…d krõ| dd…} | | dgs z)FieldStorage.getvalue..N)r6ryrp)rqr\Údefaultrpr!r!r"Úgetvaluebs    zFieldStorage.getvaluecCsB||kr:||}t|tƒr0|djS|jSn|SdS)z! Return the first value received.rN)r6ryrp)rqr\r£rpr!r!r"Úgetfirstms     zFieldStorage.getfirstcCsK||krC||}t|tƒr6dd„|DƒS|jgSngSdS)z Return list of received values.cSsg|]}|j‘qSr!)rp)r r¡r!r!r"r¢}s z(FieldStorage.getlist..N)r6ryrp)rqr\rpr!r!r"Úgetlistxs    zFieldStorage.getlistcCs;|jdkrtdƒ‚ttdd„|jDƒƒƒS)zDictionary style keys() method.Nz not indexablecss|]}|jVqdS)N)rK)r ržr!r!r"ú ‡sz$FieldStorage.keys..)ryr†Úset)rqr!r!r"r˜ƒs zFieldStorage.keyscs;|jdkrtdƒ‚t‡fdd†|jDƒƒS)z%Dictionary style __contains__ method.Nz not indexablec3s|]}|jˆkVqdS)N)rK)r rž)r\r!r"r§�sz,FieldStorage.__contains__..)ryr†Úany)rqr\r!)r\r"Ú __contains__‰s zFieldStorage.__contains__cCst|jƒƒS)z Dictionary style len(x) support.)rbr˜)rqr!r!r"Ú__len__�szFieldStorage.__len__cCs(|jdkrtdƒ‚t|jƒS)NzCannot be converted to bool.)ryr†Úbool)rqr!r!r"Ú__bool__“s zFieldStorage.__bool__cCsï|jj|jƒ}t|tƒsFtd|jt|ƒjfƒ‚|j|j |j ƒ}|j rx|d|j 7}g|_ t jj||j|jd|j d|j ƒ}x-|D]%\}}|j jt||ƒƒq¸W|jƒdS)z+Internal: read data in query string format.z%s should return bytes, got %sr1r*r‡N)r?r;r�r6rWr:rzrtr<r*r‡r‚ryr>r r rArBrTr Ú skip_lines)rqrFÚqueryr\rpr!r!r"r�˜s   zFieldStorage.read_urlencodedc Cs~|j}t|ƒs(td|fƒ‚g|_|jr�tjj|j|j|j d|j d|j ƒ}x-|D]%\}}|jj t ||ƒƒqtW|jp¬|j}|jjƒ} t| tƒsïtd|jt| ƒjfƒ‚|jt| ƒ7_xG| jƒd|jkrM| rM|jjƒ} |jt| ƒ7_qWxtƒ} d} x*|jjƒ} | | 7} | jƒscPqcW| s”P|jt| ƒ7_| j| j|j |j ƒƒ| jƒ} d| krç| d=||j| |||||j|j|j |j ƒ }|j|j7_|jj |ƒ|jsk|j|jkofdknrQPqQW|j ƒd S) z/Internal: read a part that is itself multipart.z&Invalid boundary in multipart form: %rr*r‡z%s should return bytes, got %ss--rIzcontent-lengthrN)!rŒrNr:ryr‚r>r r rArBr*r‡rTr ÚFieldStorageClassÚ __class__r?rQr6rWrzrtr‰rbrcrZfeedr<r(rŠrŽr�r®)rqr@rArBZibr¯r\rpÚklassZ first_lineÚparserZhdr_textrXrYÚpartr!r!r"r�«sV          +zFieldStorage.read_multicCsD|jdkr&|jƒ|jƒn |jƒ|jjdƒdS)zInternal: read an atomic part.rN)r�Ú read_binaryr®Ú read_linesr{rš)rqr!r!r"r‘ás    zFieldStorage.read_singleéicCsÏ|jƒ|_|j}|dkrËx¤|dkrÊ|jjt||jƒƒ}t|tƒs‚t d|jt |ƒj fƒ‚|j t |ƒ7_ |s§d|_P|jj|ƒ|t |ƒ}q'WdS)zInternal: read binary data.rz%s should return bytes, got %sr2NrL)Ú make_filer{r�r?r;ÚminÚbufsizer6rWr:rzrtr‰rbrŽr%)rqZtodorXr!r!r"rµìs   zFieldStorage.read_binarycCsV|jrtƒ|_|_ntƒ|_|_|jrH|jƒn |jƒdS)z0Internal: read lines until EOF or outerboundary.N)r‹rr{Ú_FieldStorage__filerrˆÚread_lines_to_outerboundaryÚread_lines_to_eof)rqr!r!r"r¶ýs    zFieldStorage.read_linescCs§|jdk re|jjƒt|ƒdkre|jƒ|_|jjƒ}|jj|ƒd|_|jr�|jj|ƒn"|jj|j|j |j ƒƒdS)z line is always bytes, not stringNiè) r»Útellrbr¸r{r¤r%r‹r<r*r‡)rqr[rXr!r!r"Z__writes  zFieldStorage.__writecCsOxH|jjdƒ}|jt|ƒ7_|s:d|_P|j|ƒqWdS)zInternal: read lines until EOF.r2éNirL)r?rQr‰rbrŽÚ_FieldStorage__write)rqr[r!r!r"r½s zFieldStorage.read_lines_to_eofc Cs˜d|j}|d}d}d}d}xh||jkr<P|jjd ƒ}|jt|ƒ7_|t|ƒ7}|sƒd|_P|dkrŸ||}d}|jdƒrã|rã|jƒ}||krÍP||krãd|_P|}|j dƒrd}|d d…}d}nh|j d ƒrEd }|d d…}d}n:|j dƒrsd}|d d…}d }n d}d }|j ||ƒq,Wd S)zžInternal: read lines until outerboundary. Data is read as bytes: boundaries and line ends must be converted to bytes for comparisons. s--rITrr2r¿s s NrGs FirLrMrLrL) rˆrŠr?rQr‰rbrŽrRrSÚendswithrÀ) rqÚ next_boundaryÚ last_boundaryÚdelimÚlast_line_lfendÚ_readr[Ú strippedlineZodelimr!r!r"r¼!sP            z(FieldStorage.read_lines_to_outerboundarycCsÉ|j s|jrdSd|j}|d}d}xŽ|jjdƒ}|jt|ƒ7_|snd|_P|jdƒr²|r²|jƒ}||krœP||kr²d|_P|jdƒ}q7WdS) z5Internal: skip lines until outer boundary if defined.Ns--Tr2r¿s irL)rˆrŽr?rQr‰rbrÁrc)rqrÂrÃrÅr[rÇr!r!r"r®Rs&       zFieldStorage.skip_linescCs6|jrtjdƒStjdd|jddƒSdS)a¯Overridable: return a readable & writable file. The file will be used as follows: - data is written to it - seek(0) - data is read from it The file is opened in binary mode for files, in text mode for other fields This version opens a temporary file for reading and writing, and immediately deletes (unlinks) it. The trick (on Unix!) is that the file can still be used, but it can't be opened by another process, and it will automatically be deleted when it is closed or when the current process terminates. If you want a more permanent file, you derive a class which overrides this method. If you want a visible temporary file that is nevertheless automatically deleted when the script terminates, try defining a __del__ method in a derived class which unlinks the temporary files you have created. zwb+zw+r*Únewliner$N)r‹ÚtempfileÚ TemporaryFiler*)rqr!r!r"r¸hs   zFieldStorage.make_filei )!rtrurvrwÚosr@rrr”r•r–rsr™r›rŸr¤r¥r¦r˜rªr«r­r�r°r�r‘rºrµr¶rÀr½r¼r®r¸r!r!r!r"r js< *  œ             6    1 cCsætdƒtƒtjt_ybtƒ}tƒtƒt|ƒt|ƒt ƒdd„}|dd„}tdƒ|ƒWnt ƒYnXtdƒda y/tƒ}tƒtƒt|ƒt|ƒWnt ƒYnXd S) z—Robust test CGI script, usable as main program. Write minimal HTTP headers and dump all information provided to the script in HTML form. zContent-type: text/htmlcSstdƒdS)Nz,testing print_exception() -- italics?)Úexecr!r!r!r"rf›sztest..fcSs |ƒdS)Nr!)rfr!r!r"Úg�sztest..gz9

What follows is a test, not an actual exception:

z*

Second try with a small maxlen...

é2N) Úprintr3ÚstdoutÚstderrr rrrrrrr9)r@ÚformrfrÍr!r!r"ÚtestŠs4            rÓcCs¤|dkr!tjƒ\}}}ddl}tƒtdƒ|j||ƒ|j||ƒ}tdtjdj|dd…ƒƒtj|dƒfƒ~dS)Nrz+

Traceback (most recent call last):

z
%s%s
rr2rLrL) r3Úexc_infoÚ tracebackrÏÚ format_tbÚformat_exception_onlyÚhtmlrrU)rzrpÚtbrŠrÕryr!r!r"r±s   cCs|t|jƒƒ}tƒtdƒtdƒx7|D]/}tdtj|ƒdtj||ƒƒq4WtdƒtƒdS)z#Dump the shell environment as HTML.z

Shell Environment:

z
z
z
z
N)Úsortedr˜rÏrØr)r@r˜r\r!r!r"r¿s   - cCsÒt|jƒƒ}tƒtdƒ|s3tdƒtdƒx}|D]u}tdtj|ƒdddƒ||}tdtjtt|ƒƒƒd ƒtd tjt|ƒƒƒqDWtd ƒtƒd S) z$Dump the contents of a form as HTML.z

Form Contents:

z

No form fields.z

z
ú:reú zzz
z
N)rÚr˜rÏrØrÚreprrz)rÒr˜r\rpr!r!r"rÊs    ! '! cCsƒtƒtdƒytjƒ}WnAtk rd}z!tdtjt|ƒƒƒWYdd}~XnXttj|ƒƒtƒdS)z#Dump the current directory as HTML.z#

Current Working Directory:

zOSError:N)rÏrËÚgetcwdrrØrÚstr)ÚpwdÚmsgr!r!r"rÚs /cCs0tƒtdƒtƒttjƒtƒdS)Nz

Command Line Arguments:

)rÏr3r=r!r!r!r"ræs   cCstdƒdS)z9Dump a list of environment variables used by CGI as HTML.aØ

These environment variables could have been set:

  • AUTH_TYPE
  • CONTENT_LENGTH
  • CONTENT_TYPE
  • DATE_GMT
  • DATE_LOCAL
  • DOCUMENT_NAME
  • DOCUMENT_ROOT
  • DOCUMENT_URI
  • GATEWAY_INTERFACE
  • LAST_MODIFIED
  • PATH
  • PATH_INFO
  • PATH_TRANSLATED
  • QUERY_STRING
  • REMOTE_ADDR
  • REMOTE_HOST
  • REMOTE_IDENT
  • REMOTE_USER
  • REQUEST_METHOD
  • SCRIPT_NAME
  • SERVER_NAME
  • SERVER_PORT
  • SERVER_PROTOCOL
  • SERVER_ROOT
  • SERVER_SOFTWARE
In addition, HTTP headers sent by the server may be passed in the environment as well. Here are some common variable names:
  • HTTP_ACCEPT
  • HTTP_CONNECTION
  • HTTP_HOST
  • HTTP_PRAGMA
  • HTTP_REFERER
  • HTTP_USER_AGENT
N)rÏr!r!r!r"rís'cCsetdtddƒ|jddƒ}|jddƒ}|jdd ƒ}|ra|jd d ƒ}|S) zDeprecated API.z1cgi.escape is deprecated, use html.escape insteadÚ stacklevelrGr1z&úz>r_z")rrHrl)rdÚquoter!r!r"rs cCs:ddl}t|tƒr$d}nd}|j||ƒS)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)Úrer6rWÚmatch)rdræZ _vb_patternr!r!r"rN(s   rNÚ__main__)1rwÚ __version__ÚiorrrÚ collectionsrr3rËZ urllib.parser>Z email.parserrZ email.messagerÚwarningsrrØr„rÉÚ__all__rrr#rrr)rr9r@r r r rrgrr r rÓrrrrrrrrNrtr!r!r!r"Ús\            #   E d ÿÿ"'   /