NewsNewsFeaturesDownloadsDevelopmentSupportForumDocumentsAbout Us

HttpVars 類別 參考文件
[Net_HTTP]

類別HttpVars的繼承圖:

Object 全部成員列表

公開方法(Public Methods)

 getRequestValue ($key)
 setRequest ($requestArray)
 setRequestValue ($key, $value)
 setGet ($getArray)
 getFiles ()

靜態公開方法(Static Public Methods)

 getGet ()
 getPost ()
 getSession ()
 setSession ($sessionVars)
 getCookie ()
 getRequest ()
 getServer ()
 getBaseUrl ()

詳細描述

HttpVars compatibility package, which allows to fetch some of php's basic global variables without having to worry about which version of php we're using. The problem here is that since PHP 4.1.0 things like $_REQUEST, $_POST, $_GET, etc are available, and before that their equivalents were $HTTP_GET_VARS, $HTTP_POST_VARS and so on. By using this package and calling the functions getPostVars, getGetVars, getSessionVars/setSessionVars we will get rid of any incompatibility with the version of php we are running while having access to the variables we most need.

定義在 httpvars.class.php 檔案之第 24 行.


函式成員說明文件

HttpVars::getBaseUrl  )  [static]
 

Returns the base URL of the script

傳回值:
A string containing the base URL of the script

定義在 httpvars.class.php 檔案之第 267 行.

參考 $host, 及 getServer().

被參考於 SessionManager::setSessionCookieDomain(), 及 SessionManager::setSessionCookiePath().

00268         {
00269             $serverVars = HttpVars::getServer();
00270             if ( !isset($serverVars['HTTPS']) || strtolower($serverVars['HTTPS']) != 'on' ) {
00271                 $protocol = 'http://';
00272             } else {
00273                 $protocol = 'https://';
00274             }
00275             $host      = $serverVars["HTTP_HOST"];
00276             $scriptUrl = $serverVars["PHP_SELF"];
00277 
00278             return $protocol . $host . $scriptUrl;
00279         }

HttpVars::getCookie  )  [static]
 

Returns an array with the contents of the $_COOKIE global variable, if PHP version >= 4.1.0 or the values of the array HTTP_COOKIE_VARS if we're using a lower version.

傳回值:
An associative array with all the cookies created by our application.

定義在 httpvars.class.php 檔案之第 117 行.

被參考於 getRequest().

00118         {
00119             if( phpversion() >= "4.1.0" )
00120                 $cookieVars = $_COOKIE;
00121             else {
00122                 global $HTTP_COOKIE_VARS;
00123                 $cookieVars = $HTTP_COOKIE_VARS;
00124             }
00125 
00126             return $cookieVars;
00127         }

HttpVars::getFiles  ) 
 

定義在 httpvars.class.php 檔案之第 249 行.

被參考於 AdminAddLocaleAction::_performUploadLocale(), AdminAddTemplateAction::_performUploadTemplate(), AdminAddBlogTemplateAction::_performUploadTemplate(), AdminAddResourceAction::perform(), 及 AdminAddLocaleAction::validate().

00250         {
00251             if( phpversion() >= "4.1.0" )
00252                 $files = $_FILES;
00253             else {
00254                 global $HTTP_POST_FILES;
00255                 $files = $HTTP_POST_FILES;
00256             }
00257 
00258             return $files;
00259         }

HttpVars::getGet  )  [static]
 

Returns an array with all the variables in the GET header, fetching them either from $_GET (PHP >= 4.1.0) or $HTTP_GET_VARS (PHP < 4.1.0)

傳回值:
An associative array with the values of the GET header.

定義在 httpvars.class.php 檔案之第 34 行.

參考 $_GET.

被參考於 getRequest().

00035         {
00036             if( phpversion() >= "4.1.0" )
00037                 $getVars = $_GET;
00038             else {
00039                 global $HTTP_GET_VARS;
00040                 $getVars = $HTTP_GET_VARS;
00041             }
00042 
00043             return $getVars;
00044         }

HttpVars::getPost  )  [static]
 

Returns an array with all the variables in the GET header, fetching them either from $_POST (PHP >= 4.1.0) or $HTTP_POST_VARS (PHP < 4.1.0)

傳回值:
An associative array with the values of the POST header.

定義在 httpvars.class.php 檔案之第 53 行.

被參考於 getRequest().

00054         {
00055             if( phpversion() >= "4.1.0" )
00056                 $postVars = $_POST;
00057             else {
00058                 global $HTTP_POST_VARS;
00059                 $postVars = $HTTP_POST_VARS;
00060             }
00061 
00062             return $postVars;
00063         }

HttpVars::getRequest  )  [static]
 

Returns the value of the $_REQUEST array. In PHP >= 4.1.0 it is defined as a mix of the $_POST, $_GET and $_COOKIE arrays, but it didn't exist in earlier versions. If we are running PHP < 4.1.0, then we will manually create it by merging the needed arrays.

傳回值:
An associative array containing the variables in the GET, POST and COOKIES header.

定義在 httpvars.class.php 檔案之第 138 行.

參考 $_REQUEST, getCookie(), getGet(), 及 getPost().

被參考於 getRequestValue(), AddCommentAction::perform(), Controller::process(), setRequestValue(), 及 View::View().

00139         {
00140             if( phpversion() >= "4.1.0" )
00141                 $requestVars = $_REQUEST;
00142             else {
00143                 $postVars = HttpVars::getPost();
00144                 $getVars  = HttpVars::getGet();
00145                 $cookieVars = HttpVars::getCookie();
00146 
00147                 $requestVars = array_merge( $getVars, $postVars, $cookieVars );
00148             }
00149 
00150             return $requestVars;
00151         }

HttpVars::getRequestValue key  ) 
 

returns the value of a certain key from the request

參數:
key 
傳回值:
The value, or empty if not found

定義在 httpvars.class.php 檔案之第 159 行.

參考 $request, 及 getRequest().

被參考於 View::getCurrentPageFromRequest(), AdminSiteUsersListView::getStatusFromRequest(), 及 AdminSiteBlogsListView::getStatusFromRequest().

00160         {
00161             $request = HttpVars::getRequest();
00162             if ( isset($request[$key]) )
00163                 return( $request[$key] );   
00164             return '';
00165         }

HttpVars::getServer  )  [static]
 

Returns the $_SERVER array, otherwise known as $HTTP_SERVER_VARS in versions older than PHP 4.1.0

傳回值:
An associative array with the contents of the $_SERVER array, or equivalent.

定義在 httpvars.class.php 檔案之第 237 行.

被參考於 SummaryAction::_loadLocale(), getBaseUrl(), Subdomains::getSubdomainInfoFromRequest(), Subdomains::isSubdomainUrl(), 及 EmailDnsRule::validate().

00238         {
00239             if( phpversion() >= "4.1.0" )
00240                 $serverVars = $_SERVER;
00241             else {
00242                 global $HTTP_SERVER_VARS;
00243                 $serverVars = $HTTP_SERVER_VARS;
00244             }
00245 
00246             return $serverVars;
00247         }

HttpVars::getSession  )  [static]
 

Returns an array with all the variables in the session, fetching them either from $_SESSION (PHP >= 4.1.0) or $HTTP_SESSION_VARS (PHP < 4.1.0)

傳回值:
An associative array with the values of the session.

定義在 httpvars.class.php 檔案之第 72 行.

參考 $_SESSION.

被參考於 AdminAction::_getBlogInfo(), AdminAction::_getUserInfo(), AdminAction::AdminAction(), BlogAction::BlogAction(), View::getSessionValue(), SessionManager::getSessionValue(), SessionManager::init(), AdminLogoutAction::perform(), AdminLoginAction::perform(), ResourceServerAction::ResourceServerAction(), BlogAction::saveSession(), AdminAction::saveSession(), AdminDefaultAction::sessionInfoAvailable(), View::setSessionValue(), 及 SessionManager::setSessionValue().

00073         {
00074             if( phpversion() >= "4.1.0" )
00075                 $sessionVars = $_SESSION;
00076             else {
00077                 global $HTTP_SESSION_VARS;
00078                 $sessionVars = $HTTP_SESSION_VARS;
00079             }
00080 
00081             return $sessionVars;
00082         }

HttpVars::setGet getArray  ) 
 

Sets the value of the $_GET array in PHP 4.1.0 or higher and of the $HTTP_GET_VARS if lower.

參數:
getArray An associative array with the contents of our future $_GET array
傳回值:
Returns always true.

定義在 httpvars.class.php 檔案之第 213 行.

參考 $_GET.

被參考於 setRequest().

00214         {
00215             if( phpversion() >= "4.1.0" ) {
00216                 foreach( $getArray as $key => $value ) {
00217                     $_GET["$key"] = $value;
00218                 }
00219             }
00220             else {
00221                 global $HTTP_GET_VARS;
00222                 foreach( $getArray as $key => $value ) {
00223                     $HTTP_GET_VARS["$key"] = $value;
00224                 }
00225             }
00226 
00227             return true;
00228         }

HttpVars::setRequest requestArray  ) 
 

Sets the value of the $_REQUEST array in PHP 4.1.0 or higher. If using a lower version, then the content of this array will be copied into $HTTP_GET_VARS

參數:
requestArray An associative array with the contents of our future $_REQUEST array
傳回值:
Returns always true.

定義在 httpvars.class.php 檔案之第 175 行.

參考 $_REQUEST, 及 setGet().

被參考於 AddCommentAction::perform(), 及 setRequestValue().

00176         {
00177             if( phpversion() >= "4.1.0" ) {
00178                 foreach( $requestArray as $key => $value ) {
00179                     $_REQUEST["$key"] = $value;
00180                 }
00181             }
00182             else {
00183                 HttpVars::setGet( $requestArray );
00184             }
00185 
00186             return true;
00187         }

HttpVars::setRequestValue key,
value
 

sets a value in the request

參數:
key 
value 
傳回值:
true

定義在 httpvars.class.php 檔案之第 196 行.

參考 $request, getRequest(), 及 setRequest().

00197         {
00198             $request = HttpVars::getRequest();
00199             $request["$key"] = $value;
00200             HttpVars::setRequest( $request );
00201             
00202             return true;
00203         }

HttpVars::setSession sessionVars  )  [static]
 

Saves the array in the session.

參數:
sessionVars An array that will be used as the values for the http session.
傳回值:
Always returns true.

定義在 httpvars.class.php 檔案之第 91 行.

參考 $_SESSION.

被參考於 SessionManager::init(), AdminLogoutAction::perform(), AdminLoginAction::perform(), BlogAction::saveSession(), AdminAction::saveSession(), View::setSessionValue(), 及 SessionManager::setSessionValue().

00092         {
00093             //print("saving: ");print_r($sessionVars);
00094 
00095             if( phpversion() >= "4.1.0" ) {
00096                 foreach( $sessionVars as $key => $value ) {
00097                     $_SESSION["$key"] = $value;
00098                 }
00099             }
00100             else {
00101                 global $HTTP_SESSION_VARS;
00102                 foreach( $sessionVars as $key => $value ) {
00103                     $HTTP_SESSION_VARS["$key"] = $value;
00104                 }
00105             }
00106 
00107             return true;
00108         }


此類別(class) 文件是由下列檔案中產生: