⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
📖 第 1 页 / 共 3 页
字号:
error message can be obtained from C<$app-E<gt>errstr>.=head2 $app->send_http_header([ $content_type ])Sends the HTTP header to the client; if C<$content_type> is specified, theI<Content-Type> header is set to C<$content_type>. Otherwise, C<text/html> isused as the default.In a L<mod_perl> context, this calls the L<Apache::send_http_header> method;in a CGI context, the L<CGI::header> method is called.=head2 $app->print(@data)Sends data C<@data> to the client.In a L<mod_perl> context, this calls the L<Apache::print> method; in a CGIcontext, data is printed directly to STDOUT.=head2 $app->bake_cookie(%arg)Bakes a cookie to be sent to the client.C<%arg> can contain any valid parameters to the C<new> methods ofL<CGI::Cookie> (or L<Apache::Cookie>--both take the same parameters). Theseinclude C<-name>, C<-value>, C<-path>, C<-secure>, and C<-expires>.If you do not include the C<-path> parameter in C<%arg>, it will be setautomatically to C<$app-E<gt>path> (below).In a L<mod_perl> context, this method uses L<Apache::Cookie>; in a CGI context,it uses L<CGI::Cookie>.This method will automatically assign a "secure" flag for the cookie if it the current HTTP request is using the https protocol. To forcibly disable the secure flag, provide a C<-secure> argument with a value of 0.=head2 $app->cookiesReturns a reference to a hash containing cookie objects, where the objects areeither of class L<Apache::Cookie> (in a L<mod_perl> context) or L<CGI::Cookie>(in a CGI context).=head2 $app->add_breadcrumb($name, $uri)Adds to the navigation history path that is displayed to the end user whenusing the application.  The last breadcrumb should always be a reference tothe active mode of the application. Example:    $app->add_breadcrumb('Edit Foo', '?__mode=edit&_type=foo');=head2 $app->add_methods(%arg)Used to supply the application class with a list of available run modes andthe code references for each of them. C<%arg> should be a hash list ofmethods and the code reference for it. Example:    $app->add_methods(        'one' => \&one,        'two' => \&two,        'three' => \&three,    );=head2 $app->app_pathReturns the path portion of the active URI.=head2 $app->app_uriReturns the current application's URI.=head2 $app->mt_pathReturns the path portion of the URI that is used for accessing the MT CGIscripts.=head2 $app->mt_uriReturns the full URI of the MT "admin" script (typically a reference tomt.cgi).=head2 $app->blogReturns the active weblog, if available. The I<blog_id> queryparameter identifies this weblog.=head2 $app->build_page($tmpl_name, \%param)Builds an application page to be sent to the client; the page name is specifiedin C<$tmpl_name>, which should be the name of a template containing validL<HTML::Template> markup. C<\%param> is a hash ref whose keys and values willbe passed to L<HTML::Template::param> for use in the template.On success, returns a scalar containing the page to be sent to the client. Onfailure, returns C<undef>, and the error message can be obtained fromC<$app-E<gt>errstr>.=head2 How does build_page find a template?The C<build_page> function looks in several places for an apptemplate. Two configuration directives can modify these search paths,and application and plugin code can also affect them.The I<TemplatePath> config directive is an absolute path to the directorywhere MT's core application templates live. It defaults to the I<mt_dir>plus an additional path segment of 'tmpl'.The optional I<AltTemplatePath> config directive is a path (absoluteor relative) to a directory where some 'override templates' maylive. An override template takes the place of one of MT's coreapplication templates, and is used interchangeably with the coretemplate. This allows power users to customize the look and feel ofthe MT application. If I<AltTemplatePath> is relative, its base pathis the value of C<TemplatePath>.Next, any application built on the C<MT::App> foundation can defineits own I<template_dir> parameter, which identifies a subdirectory ofTemplatePath (or AltTemplatePath) where that application's templatescan be found. I<template_dir> defaults to C<cms>. Most templates willbe found in this directory, but sometimes the template search willfall through to the parent directory, where a default error templateis found, for example. I<template_dir> should rightly have been namedI<application_template_dir>, since it is application-specific.Finally, a plugin can specify its I<plugin_template_path>, whichlocates a directory where the templates for that plugin's owninterface are found. If the I<plugin_template_path> is relative, itmay be relative to either the I<app_dir>, or the I<mt_dir>; the formertakes precedence if it exists. (for a definition of I<app_dir> andI<mt_dir>, see L<perldoc MT>)Given these values, the order of search is as follows:=over 4=item * I<plugin_template_path>=item * I<AltTemplatePath>=item * I<AltTemplatePath>F</>I<template_dir>=item * I<TemplatePath>/I<template_dir>=item * I<TemplatePath>=backIf a template with the given name is not found in any of theselocations, an ugly error is thrown to the user.=head2 $app->cookie_val($name)Returns the value of a given cookie.=head2 $app->delete_param($param)Clears the value of a given CGI parameter.=head2 $app->errtrans($msg[, @param])Translates the C<$msg> text, passing through C<@param> for any parameterswithin the message. This also sets the error state of the application,assinging the translated text as the error message.=head2 $app->get_header($header)Returns the value of the specified HTTP header.=head2 MT::App->handlerThe mod_perl handler used when the application is run as a nativemod_perl handler.=head2 $app->init(@param)Initializes the application object, setting default values and establishingthe parameters necessary to run.  The @param values are passed throughto the parent class, the C<MT> package.This method needs to be invoked by any subclass when the object isinitialized.=head2 $app->is_authorizedReturns a true value if the active user is authorized to access theapplication. By default, this always returns true; subclasses mayoverride it to check app-specific authorization. A login attempt willbe rejected with a generic error message at the MT::App level, ifis_authorized returns false, but MT::App subclasses may wish toperform additional checks which produce more specific error messages.Subclass authors can assume that $app->{author} is populated with theauthenticated user when this routine is invoked, and that CGI queryobject is available through $app->{query} and $app->param().=head2 $app->is_secureReturns a boolean result based on whether the application request ishappening over a secure (HTTPS) connection.=head2 $app->l10n_filterAlias for C<MT-E<gt>translate_templatized>.=head2 $app->param($name[, $value])Interface for getting and setting CGI query parameters. Example:    my $title = $app->param('entry_title');Versions of MT before 3.16 did not support the MT::App::param()method. In that environment, $app->{query} is a CGI object whoseC<param> method works identically with this one.=head2 $app->param_hashReturns a hash reference containing all of the query parameter namesand their values. Example:    my $data = $app->param_hash;    my $title = $data->{entry_title};Available since version 3.0D.=head2 $app->post_runThis method is invoked, with no parameters, immediately following theexecution of the requested C<__mode> handler. Its return value is ignored.C<post_run> will be invoked whether or not the C<__mode> handler returns anerror state through the MT::ErrorHandler mechanism, but it will not beinvoked if the handler C<die>s.App subclasses can override this method with tasks to be executedafter any C<__mode> handler but before the page is delivered to theclient. Such a method should invoke C<SUPER::post_run> to ensure thatMT's core post-run tasks are executed.=head2 $app->pre_runThis method is invoked, with no parameters, before dispatching to therequested C<__mode> handler. Its return value is ignored.C<pre_run> is not invoked if the request could not be authenticated.If C<pre_run> is invoked and does not C<die>, the C<__mode> handlerB<will> be invoked.App subclasses can override this method with tasks to be executedbefore, and regardless of, the C<__mode> specified in therequest. Such an overriding method should invoke C<SUPER::pre_run> toensure that MT's core pre-run tasks are executed.=head2 $app->query_stringReturns the CGI query string of the active request.=head2 $app->request_contentReturns a scalar containing the POSTed data of the active HTTPrequest. This will force the request body to be read, even if$app->{no_read_body} is true. TBD: document no_read_body.=head2 $app->request_methodReturns the method of the active HTTP request, typically either "GET"or "POST".=head2 $app->response_content_type([$type])Gets or sets the HTTP response Content-Type header.=head2 $app->response_code([$code])Gets or sets the HTTP response code: the numerical value that beginsthe "status line." Defaults to 200.=head2 $app->response_message([$message])Gets or sets the HTTP response message, better known as the "reasonphrase" of the "status line." E.g., if these calls were executed:   $app->response_code("404");   $app->response_message("Thingy Not Found");This status line might be returned to the client:   404 Thingy Not FoundBy default, the reason phrase is an empty string, but an appropriatereason phrase may be assigned by the webserver based on the responsecode.=head2 $app->set_header($name, $value)Adds an HTTP header to the response with the given name and value.=head2 $app->validate_magicChecks for a I<magic_token> HTTP parameter and validates it for the currentauthor.  If it is invalid, an error message is assigned to the applicationand a false result is returned. If it is valid, it returns 1. Example:    return unless $app->validate_magic;To populate a form with a valid magic token, provide a HTML::Templateparameter named "needs_magic". Example:    $params->{needs_magic} = 1;    $app->build_page("myform.tmpl", $params);Then, within your template, place the token value in a hidden form field:    <input type="hidden" name="magic_token" value="<TMPL_VAR NAME=MAGIC_TOKEN>" />If you're protecting a hyperlink, add the token to the query parametersfor that link.=head2 $app->redirect($url, [option1 => option1_val, ...])Redirects the client to the URL C<$url>. If C<$url> is not an absoluteURL, it is prepended with the value of C<$app-E<gt>base>.By default, the redirection is accomplished by means of a Locationheader and a 302 Redirect response.If the option C<UseMeta => 1> is given, the request will be redirectedby issuing a text/html entity body that contains a "meta redirect"tag. This option can be used to work around clients that won't acceptcookies as part of a 302 Redirect response.=head2 $app->baseThe protocol and domain of the application. For example, with the full URIF<http://www.foo.com/mt/mt.cgi>, this method will return F<http://www.foo.com>.=head2 $app->pathThe path component of the URL of the application directory. Forexample, with the full URL F<http://www.foo.com/mt/mt.cgi>, thismethod will return F</mt/>.=head2 $app->scriptIn CGI mode, the filename of the active CGI script. For example, withthe full URL F<http://www.foo.com/mt/mt.cgi>, this method will returnF<mt.cgi>.In mod_perl mode, the Request-URI without any query string.=head2 $app->uriThe concatenation of C<$app-E<gt>path> and C<$app-E<gt>script>. For example,with the full URI F<http://www.foo.com/mt/mt.cgi>, this method will returnF</mt/mt.cgi>.=head2 $app->path_infoThe path_info for the request (that is, whatever is left in the URIafter removing the path to the script itself).=head2 $app->log($msg)Adds the message C<$msg> to the activity log. The log entry will be taggedwith the IP address of the client running the application (that is, of thebrowser that made the HTTP request), using C<$app-E<gt>remote_ip>.=head2 $app->trace(@msg)Adds a trace message by concatenating all the members of C<@msg> to theinternal tracing mechanism; trace messages are then displayed at thetop of the output page sent to the client.  These messages aredisplayed when the I<DebugMode> configuration parameter isenabled. This is useful for debugging.=head2 $app->remote_ipThe IP address of the client.In a L<mod_perl> context, this calls L<Apache::Connection::remote_ip>; in aCGI context, this uses C<$ENV{REMOTE_ADDR}>.=head1 AUTHOR & COPYRIGHTSPlease see the L<MT> manpage for author, copyright, and license information.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -