Link | lp_page_path |
Author | Bil Corry |
Category | Utility |
Version | 8.5.x |
License | Public Domain |
Posted | 02 Sep 2006 |
Updated | 22 May 2008 |
More by this author... |
Returns page path information, depending on the member tag used.
Security warning! ->host returns the Host header, and if missing, it returns server_name. Because the Host header
can be spoofed to anything by the client, you should ensure your webserver is configured to only serve known Hosts and/or
check that the value ->host returns one of your known hosts within Lasso.
Requires [lp_file_listDirectory]
Example
----------- HOST ----------------
->host = old.corry.biz
->subhost = old
->domain = corry.biz
->port = 80
->http = http://
->ip = 10.0.0.115
----------- FILE NAME -----------
->filename = lp.853.lasso
->filestem = lp.853
->filesuffix = lasso
----------- WEB PATH ------------
->webpath = /test/test.folder/
->folder = test.folder
->folderdepth = 2
->folderlist = array: (test), (test.folder)
----------- FILE PATH -----------
->filepath = C://Program Files/Apache Group/Apache2/htdocs/test/test.folder/
->webroot = C://Program Files/Apache Group/Apache2/htdocs/
----------- DIRECTORY -----------
->files = array: (lp.853.lasso), (that.lasso), (this.lasso)
->folders = array: (thatfolder), (thisfolder)
----------- URL -----------------
->url = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&-session=test:123123&hello=world&abc=123
->url:
-nosession = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&hello=world&abc=123
->url:
-noargs = http://old.corry.biz/test/test.folder/lp.853.lasso
->url:
-fullargs = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&-session=test:123123&hello=world&abc=123&f1=v1&f1=v2&f2=v3&-session=test%3A123123&submit=POST
->url:
-fullargs,
-nosession = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&hello=world&abc=123&f1=v1&f1=v2&f2=v3&submit=POST
Example ----------- HOST ---------------- ->host = [lp_page_path->host] ->subhost = [lp_page_path->subhost] ->domain = [lp_page_path->domain] ->port = [lp_page_path->port] ->http = [lp_page_path->http] ->ip = [lp_page_path->ip] ----------- FILE NAME ----------- ->filename = [lp_page_path->filename] ->filestem = [lp_page_path->filestem] ->filesuffix = [lp_page_path->filesuffix] ----------- WEB PATH ------------ ->webpath = [lp_page_path->webpath] ->folder = [lp_page_path->folder] ->folderdepth = [lp_page_path->folderdepth] ->folderlist = [lp_page_path->folderlist] ----------- FILE PATH ----------- ->filepath = [lp_page_path->filepath] ->webroot = [lp_page_path->webroot] ----------- DIRECTORY ----------- ->files = [lp_page_path->files] ->folders = [lp_page_path->folders] ----------- URL ----------------- ->url = [lp_page_path->url] ->url: -nosession = [lp_page_path->(url: -nosession)] ->url: -noargs = [lp_page_path->(url: -noargs)] ->url: -fullargs = [lp_page_path->(url: -fullargs)] ->url: -fullargs, -nosession = [lp_page_path->(url: -fullargs, -nosession)]
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
[ define_type:'lp_page_path', -description='Returns page path information, depending on the member tag used.', -privileged; // Based on code originally from Greg Willits /* Security warning! ->host returns the Host header, and if missing, it returns server_name. Because the Host header can be spoofed to anything by the client, you should ensure your webserver is configured to only serve known Hosts and/or check that the value ->host returns one of your known hosts within Lasso. */ // create page-level cache for the more complicated calcs if: !(var_defined:'_lp_page_path_cache'); (var:'_lp_page_path_cache') = map; /if; // ----------- HOST ---------------- // ->host = www.mysite.com // ->subhost = www // ->domain = mysite.com // ->port = 80 // ->http = http:// OR https:// // ->ip = 10.1.10.10 // www.mysite.com define_tag:'host'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = (string_findregexp:client_headers,-find='(?mi)^(?:http_)?host:\\s+([^\\s]+)'); if: #temp->size == 2; #temp = #temp->(get:2); else; #temp = server_name; /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // www define_tag:'subhost'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = self->host->(split:'.'); if: #temp->size <= 2; #temp = string; else; #temp->remove; #temp->remove; #temp = #temp->(join:'.'); /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // mysite.com define_tag:'domain'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = self->host->(split:'.'); if: #temp->size == 1; #temp = #temp->(get:1); else; #temp = (#temp->(get: #temp->size - 1)) '.' (#temp->(get: #temp->size)); /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // 80 define_tag:'port'; return: server_port; /define_tag; // http:// OR https:// define_tag:'http'; return: server_port == 443 ? 'https://' | 'http://'; /define_tag; // 10.1.10.10 define_tag:'ip'; return: server_ip; /define_tag; // ----------- FILE NAME ----------- // ->filename = default.lasso // ->filestem = default // ->filesuffix = lasso // default.lasso define_tag:'filename'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = response_filepath->(split:'/')->last; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // default define_tag:'filestem'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = response_filepath->(split:'/')->last->(split:'.'); if: #temp->size == 1; #temp = #temp->(get:1); else; #temp->remove; #temp = #temp->(join:'.'); /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // lasso define_tag:'filesuffix'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = response_filepath->(split:'/')->last->(split:'.'); if: #temp->size <= 1; // no dot found, thus no extension #temp = string; else; #temp = #temp->last; /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // ----------- WEB PATH ------------ // ->webpath = /test/temp/ // ->folder = temp // ->folderdepth = 2 // ->folderlist = array:(test),(temp) // /test/temp/ define_tag:'webpath'; return: response_path; /define_tag; // temp define_tag:'folder'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = response_path->(removetrailing:'/') &->(split:'/')->last; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // 2 define_tag:'folderdepth'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = response_path->(split:'/')->size - 2; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // array:(test),(temp) define_tag:'folderlist'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp'=response_path->(split:'/'); #temp->(remove:1); #temp->remove; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // ----------- FILE PATH ----------- // ->filepath = C://Inetpub/wwwroot/test/temp/ // ->webroot = C://Inetpub/wwwroot/ // C://Inetpub/wwwroot/test/temp/ define_tag:'filepath'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = string; if: response_filepath->size == 0; // check if in LassoStartup #temp = _admin_servicepath; // C://Program Files/OmniPilot Software/Lasso Professional 8/LassoSites/default-1/LassoStartup/ else; #temp = response_localpath->(substring: 1, response_localpath->length - response_filepath->(split:'/')->last->length ); /if; if: !(#temp->(endswith:'/')); #temp += '/'; /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // C://Inetpub/wwwroot/ define_tag:'webroot'; if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:tag_name); /if; local:'temp' = string; if: response_filepath->size == 0; // check if in LassoStartup #temp = _admin_servicepath; // C://Program Files/OmniPilot Software/Lasso Professional 8/LassoSites/default-1/ else; #temp = response_localpath->(substring: 1, response_localpath->length - response_filepath->length + 1 ); /if; if: !(#temp->(endswith:'/')); #temp += '/'; /if; $_lp_page_path_cache->(insert:tag_name=#temp); return: #temp; /define_tag; // ----------- DIRECTORY ----------- // ->files = array:(default.lasso),(somefile.lasso),(otherfile.txt) // ->folders = array:(folder_a),(folder_b),(folder_c) // array:(default.lasso),(somefile.lasso),(otherfile.txt) define_tag:'files'; local:'return'=array; local:'dir' = (lp_file_listdirectory: response_path); iterate: #dir, local:'item'; if: !(#item->(endswith:'/')); #return->(insert:#item); /if; /iterate; return: #return; /define_tag; // array:(folder_a),(folder_b),(folder_c) define_tag:'folders'; local:'return'=array; local:'dir' = (lp_file_listdirectory: response_path); iterate: #dir, local:'item'; if: #item->(endswith:'/'); #item->(removetrailing:'/'); #return->(insert:#item); /if; /iterate; return: #return; /define_tag; // ----------- URL ----------------- //->url = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&-session=test:123123&hello=world&abc=123 // //->url: // -nosession = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&hello=world&abc=123 // //->url: // -noargs = http://old.corry.biz/test/test.folder/lp.853.lasso // //->url: // -fullargs = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&-session=test:123123&hello=world&abc=123 // //->url: // -fullargs, // -nosession = http://old.corry.biz/test/test.folder/lp.853.lasso?a=2&hello=world&abc=123 define_tag:'url', -optional='noargs', // url sans the url params -optional='nosession', // url with url params, but no session param -optional='fullargs'; // url with get/post params if: $_lp_page_path_cache->(find:tag_name)->size; return: $_lp_page_path_cache->(find:(tag_name + (local_defined:'noargs') + (local_defined:'nosession') + (local_defined:'fullargs'))); /if; local:'temp' = string; if: server_port == 443; #temp += 'https://' self->host; else: server_port == 80; #temp += 'http://' self->host; else; #temp += 'http://' self->host ':' server_port; /if; #temp += response_filepath; if: (local_defined:'noargs'); return: #temp; /if; local:'args' = client_getparams; if: (local_defined:'fullargs') && client_postparams->size; #args->(merge: client_postparams); /if; loop: -from=#args->size, -to=1, -by=-1; if: (local_defined:'nosession') && #args->(get: loop_count)->(contains:'-session='); #args->(remove: loop_count); else: #args->(get: loop_count)->type == 'pair'; #args->(get: loop_count) = (encode_stricturl: (decode_url: #args->(get: loop_count)->name)) + '=' + (encode_stricturl: (decode_url: #args->(get: loop_count)->value)); else; #args->(get: loop_count) = (encode_stricturl: (decode_url: #args->(get: loop_count))); /if; /loop; if: #args->size; #temp += '?' + #args->(join:'&'); /if; $_lp_page_path_cache->(insert:(tag_name + (local_defined:'noargs') + (local_defined:'nosession') + (local_defined:'fullargs'))=#temp); return: @#temp; /define_tag; /define_type; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft