Advertisement
Guest User

MikelSV StormServer / RewriteEngine

a guest
Jun 10th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1.         //RewriteEngine
  2.         if(listen_http_options.GetOptionGlobal("RewriteEngine", host).incompareu("on")){
  3.             ilink.Link(url);
  4.  
  5.             // rewrite
  6.             listen_http_option *rw_host = host;
  7.             listen_http_option *opt = 0;
  8.             while((opt = listen_http_options.FindOption("RewriteRule", opt, rw_host)) || rw_host && (opt = listen_http_options.FindOption("RewriteRule", opt = 0, rw_host = 0))){
  9.                 // init
  10.                 VString rule, result, options;
  11.                 const char *errptr; int erroffset;
  12.                 int opt_l = 0, opt_qsa = 0;
  13.                 int arr[255];
  14.  
  15.                 VString rurl = ilink.GetPathFile().str(1);
  16.                 rule = PartLine(opt->val, result, " ");
  17.                 result = PartLine(result, options, " ");
  18.                
  19.                 // compile
  20.                 pcre *p = pcre_compile(it.set(rule), 0, &errptr, &erroffset, 0);               
  21.                 // find
  22.                 int f = pcre_exec(p, 0, rurl, rurl, 0, 0, arr, 255);
  23.  
  24.                 // found
  25.                 if(f > 0){
  26.                     // options
  27.                     if(options[0] == '[' && options.endo() == ']'){
  28.                         options = options.str(1, -2);
  29.                    
  30.                         while(options){
  31.                             VString k = PartLine(options, options, ",");
  32.                             if(k == "L" || k == "last")
  33.                                 opt_l = 1;
  34.                             else if(k == "SQA" || k == "qsappend")
  35.                                 opt_qsa = 1;
  36.                         }
  37.                     }
  38.  
  39.                     it.Reserv(prmf_pcre_result(0, 0, result, result, rurl, rule, arr, f, opt_qsa, ilink.iquest));
  40.                     prmf_pcre_result(it, it, result, result, rurl, rule, arr, f, opt_qsa, ilink.iquest);
  41.                     ilink.Link(url = it);
  42.                 }
  43.  
  44.                 pcre_free(p);
  45.  
  46.                 if(opt_l)
  47.                     break;             
  48.             }
  49.         }
  50. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement