Guest User

sony 2

a guest
May 6th, 2011
2,013
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. umask(02);
  4.  
  5. use CGI;
  6.  
  7. # Setting Security for the script
  8. $CGI::POST_MAX=1024 * 100; # max 100K posts
  9. $CGI::DISABLE_UPLOADS = 1; # no uploads
  10.  
  11. # Setting Global Variables
  12. $| = 1;
  13. $dbPath = "/w1/htmldocs/shared/santa/dbs/";
  14. $templatePath = "/w1/htmldocs/shared/santa/templates/";
  15. $mailprog = "/usr/lib/sendmail";
  16. $wishlistHome ="/santa/";
  17.  
  18. #print "Content-type: text/html\n\n";
  19.  
  20. $query = new CGI;
  21.  
  22. %form = $query->Vars;
  23. $action = $query->url_param('action');
  24. $form{'model'} = $form{'model'} || $query->url_param('model');
  25. $form{'list'} = $form{'list'} || $query->url_param('list');
  26.  
  27. if($action eq "login") {
  28. if(&login($query, $form{email}, $form{password})) {
  29. &setCookie($query, $form{email});
  30. &selectList($query, $form{'email'}, "", $form{'model'});
  31. } else {
  32. $form{'error'} = 1;
  33. &showPage("${templatePath}login.html", $query, "content", %form);
  34. }
  35. } elsif($action eq "register") {
  36. if($form{'error'} = &validateForm($query, %form)) {
  37. &showPage("${templatePath}register.html", $query, "content", %form);
  38. } else {
  39. if($form{'age'} > 13) {
  40. &createAccount($query, %form);
  41. &recordSweepStake(%form) if $form{'sweepstake'};
  42. &setCookie($query, $form{'email'});
  43. &selectList($query, $form{'email'}, "", $form{'model'});
  44. } else {
  45. dbmopen(%MINOR, "${dbPath}.minor", 0664)
  46. || &error("minor", "can't create minor database");
  47. $MINOR{$form{'email'}} = $form{'age'};
  48. dbmclose(%MINOR);
  49. &showPage("${templatePath}minor.html", $query, "content", %form);
  50. }
  51. }
  52. } elsif($action eq "showreg") {
  53. &showPage("${templatePath}register.html", $query, "content", %form);
  54. } elsif($action eq "santa") {
  55. &showSanta($query, $form{'u'}, $form{'l'}, $form{'s'});
  56. } elsif($action eq "buy") {
  57. $products = join("~", ($form{'id1'}, $form{'id2'}, $form{'id3'}, $form{'id4'}, $form{'id5'}, $form{'id6'}, $form{'id7'}, $form{'id8'}, $form{'id9'}, $form{'id10'}));
  58. $products =~ s/~+/~/g;
  59. $products =~ s/~$//g;
  60. print "Status: 302\n";
  61. print "Location: http://sh1.yahoo.com/rmi/http://www.sonystyle.com/rmi-product-url/http://www.sonystyle.com/compass.santa.html?prodids=$products\n\n";
  62. } else {
  63. $user = $query->cookie('wishlistID');
  64. if($user) {
  65. my(%_U);
  66. dbmopen(%_U, "${dbPath}.accounts", undef)
  67. || &error("other", $q, "Can't read golbal accounts database\n");
  68. unless(defined($_U{$user})) {
  69. dbmclose(%_U);
  70. &setCookie($query, "", "now");
  71. &showPage("${templatePath}login.html", $query, "", %form);
  72. exit 0;
  73. }
  74. dbmclose(%_U);
  75. } else {
  76. &showPage("${templatePath}login.html", $query, "content", %form);
  77. exit 0;
  78. }
  79.  
  80. if($action eq "add") {
  81. if($form{'choose.x'}) {
  82. &add($query, $user, $form{'model'}, $form{'list'}) if $form{'model'};
  83. &showListContent($query, $user, $form{'list'}, "content");
  84. } elsif($form{'delete.x'}) {
  85. &deleteList($query, $user, $form{'list'});
  86. &selectList($query, $user, "", $form{'model'}, "content");
  87. } else {
  88. print "Status: 302\n";
  89. print "LOCATION: $wishlistHome\n\n";
  90. }
  91. } elsif($action eq "create") {
  92. my(%LISTS, $list, $count);
  93. dbmopen(%LISTS, "$dbPath$user.lists", 0664)
  94. || &error("create list", $query, "Can't write to lists for $user");
  95. $LISTS{$form{'wishlist'}} = $LISTS{$form{'wishlist'}};
  96. $count = 0;
  97. foreach $list (keys(%LISTS)) {
  98. $count ++;
  99. last if $count > 1;
  100. }
  101. dbmclose(%LISTS);
  102. if($form{'model'} and $count == 1) {
  103. &add($query, $user, $form{'model'}, $form{'wishlist'});
  104. &showListContent($query, $user, $form{'wishlist'}, "content");
  105. } else {
  106. &selectList($query, $user, $form{'wishlist'}, $form{'model'}, "content");
  107. }
  108. } elsif($action eq "selectlist") {
  109. my(%LISTS, $list, $count);
  110. dbmopen(%LISTS, "$dbPath$user.lists", 0664)
  111. || &error("select list", $query, "Can't read lists for $user");
  112. $count = 0;
  113. foreach $key (keys(%LISTS)) {
  114. $count ++;
  115. $list = $key;
  116. last if $count > 1;
  117. }
  118. dbmclose(%LISTS);
  119. if($form{'model'} and $count == 1) {
  120. &add($query, $user, $form{'model'}, $list);
  121. &showListContent($query, $user, $list, "content");
  122. } else {
  123. &selectList($query, $user, "", $form{'model'}, "content");
  124. }
  125. } elsif($action eq "deleteitem") {
  126. &deleteItem($query, $user, $form{'model'}, $form{'list'});
  127. &showListContent($query, $user, $list, "content");
  128. } elsif($action eq "mail") {
  129. &mailSanta($query, $user, %form);
  130. &showPage("${templatePath}thankyou.html", $query, "content");
  131. } else {
  132. &showListContent($query, $user, $form{'list'}, "content");
  133. }
  134. }
  135. #&debug();
  136.  
  137. sub debug {
  138. my $user = $query->cookie('wishlistID');
  139. print "<h2>Action is $action and user is $user</h2>\n";
  140. foreach $key (keys(%form)) {
  141. print "form $key has val $form{$key}<br>\n";
  142. }
  143. print "<hr>\n";
  144. foreach $key (keys(%ENV)) {
  145. print "$key has val $ENV{$key}<br>\n";
  146. }
  147. }
  148.  
  149. sub showListContent {
  150. my($q, $u, $l, $head) = @_;
  151. my(%LISTS, %d, $list, $content, @products, %PRODUCTS);
  152. if(-e "$dbPath$u.lists.dir") {
  153. dbmopen(%LISTS, "$dbPath$u.lists", undef)
  154. || &error("showListContent", $q, "Can't read from lists for $u");
  155. foreach $list (sort keys(%LISTS)) {
  156. $l = $list unless $l;
  157. if($l eq $list) {
  158. $d{'lists'} .= "<option value=\"$list\" selected>$list</option>";
  159. $content = $LISTS{$l};
  160. } else {
  161. $d{'lists'} .= "<option value=\"$list\">$list</option>";
  162. }
  163. }
  164. $d{'list'} = $l;
  165. dbmclose(%LISTS);
  166. &showPage("${templatePath}wishlist.head.html", $q, $head, %d);
  167. dbmopen(%PRODUCTS, "${dbPath}.products", undef)
  168. || &error("showListContent", $q, "Can't read product lists");
  169. @products = split(/ # /, $content);
  170. foreach $content (@products) {
  171. $d{'img'} = $d{'model'} = $content;
  172. ($d{'id'}, $d{'price'}, $d{'name'}, $d{'link'}) = split(/ # /, $PRODUCTS{$content});
  173. $d{'price'} = "\$$d{'price'}";
  174. $d{'img'} =~ s/\///g;
  175. &showPage("${templatePath}wishlist.loop.html", $q, "", %d);
  176. }
  177. dbmclose(%PRODUCTS);
  178. &showPage("${templatePath}wishlist.foot.html", $q, "", %d);
  179. } else {
  180. &selectList($q, $u, $l, "", $head);
  181. }
  182. }
  183.  
  184. sub deleteList {
  185. my($q, $user, $mylist) = @_;
  186. my(%_LISTS);
  187.  
  188. dbmopen(%_LISTS, "${dbPath}$user.lists", 0664)
  189. || &error("add", $q, "Can't add $i to list $w for $u");
  190. delete($_LISTS{$mylist});
  191. dbmclose(%_LISTS);
  192. }
  193.  
  194. sub selectList {
  195. my($q, $user, $mylist, $item, $content) = @_;
  196. my(%d);
  197.  
  198. $d{'model'} = $item;
  199. if(-e "$dbPath$user.lists.dir") {
  200. my(%LISTS, $list);
  201. dbmopen(%LISTS, "$dbPath$user.lists", undef)
  202. || &error("selectlist", $q, "Can't read from lists for $user");
  203. foreach $list (sort keys(%LISTS)) {
  204. if($mylist eq $list) {
  205. $d{'lists'} .= "<option value=\"$list\" selected>$list</option>";
  206. } else {
  207. $d{'lists'} .= "<option value=\"$list\">$list</option>";
  208. }
  209.  
  210. }
  211. dbmclose(%LISTS);
  212. &showPage("${templatePath}selectlist.head.html", $q, $content, %d);
  213. if($d{'lists'}) {
  214. &showPage("${templatePath}selectlist.havelist.html", $q, "", %d);
  215. } else {
  216. &showPage("${templatePath}selectlist.blank.html", $q, "", %d);
  217. }
  218. } else {
  219. &showPage("${templatePath}selectlist.head.html", $q, $content, %d);
  220. &showPage("${templatePath}selectlist.blank.html", $q, "", %d);
  221. }
  222. &showPage("${templatePath}selectlist.foot.html", $q);
  223. }
  224.  
  225. sub add {
  226. my($q, $u, $i, $wishlist) = @_;
  227. my(%_LISTS);
  228.  
  229. dbmopen(%_LISTS, "${dbPath}$u.lists", 0664)
  230. || &error("add", $q, "Can't add $i to list $wishlist for $u");
  231. if($_LISTS{$wishlist} !~ /$i/) {
  232. $_LISTS{$wishlist} = join(" # ", (split(/ # /, $_LISTS{$wishlist}), $i));
  233. }
  234. dbmclose(%_LISTS);
  235. }
  236.  
  237. sub deleteItem {
  238. my($q, $u, $i, $w) = @_;
  239. my(%_LISTS);
  240.  
  241. dbmopen(%_LISTS, "${dbPath}$u.lists", 0664)
  242. || &error("add", $q, "Can't add $i to list $w for $u");
  243. if($_LISTS{$w} =~ /$i/) {
  244. $_LISTS{$w} =~ s/$i//g;
  245. $_LISTS{$w} =~ s/( # )+/$1/g;
  246. $_LISTS{$w} =~ s/^ # //g;
  247. $_LISTS{$w} = "" if $_LISTS{$w} eq " # ";
  248. }
  249. dbmclose(%_LISTS);
  250. }
  251.  
  252. sub setCookie {
  253. my($q, $_id) = @_;
  254. my $cookie = $q->cookie(-name=>'wishlistID',
  255. -value=>$_id,
  256. -secure=>0);
  257. print $q->header(-cookie=>$cookie);
  258. }
  259.  
  260. sub login {
  261. my($q, $_id, $_pw) = @_;
  262. my(%_U);
  263. if(-e "${dbPath}.accounts") {
  264. dbmopen(%_U, "${dbPath}.accounts", undef)
  265. || &error("login", $q, "Can't read golbal accounts database\n");
  266. } else {
  267. dbmopen(%_U, "${dbPath}.accounts", 0664)
  268. || &error("login", $q, "Can't read golbal accounts database\n");
  269. }
  270.  
  271. if(defined($_U{"\L$_id"}) and ($_U{"\L$_id"} eq $_pw)) {
  272. dbmclose(%_U);
  273. return 1;
  274. } else {
  275. dbmclose(%_U);
  276. return 0;
  277. }
  278. }
  279.  
  280. sub validateForm {
  281. my($q, %_data) = @_;
  282. my($error) = "";
  283. my($_ACCTS);
  284.  
  285. # Check for error
  286. $error = "";
  287.  
  288. if(-e "${dbPath}.minor") {
  289. dbmopen(%_ACCTS, "${dbPath}.minor", undef)
  290. || &error("validateForm", $q, "Can't read minor database");
  291. } else {
  292. dbmopen(%_ACCTS, "${dbPath}.minor", 0664)
  293. || &error("validateForm", $q, "Can't create minor database");
  294. }
  295.  
  296. if(defined($_ACCTS{$_data{'email'}})) {
  297. &showPage("${templatePath}minor.html", $query, "content", %form);
  298. exit 0;
  299. }
  300. dbmclose(%_ACCTS);
  301.  
  302. if(-e "${dbPath}.accounts") {
  303. dbmopen(%_ACCTS, "${dbPath}.accounts", undef)
  304. || &error("validateForm", $q, "Can't read accounts database");
  305. } else {
  306. dbmopen(%_ACCTS, "${dbPath}.accounts", 0664)
  307. || &error("validateForm", $q, "Can't create accounts database");
  308. }
  309.  
  310. if(defined($_ACCTS{$_data{'email'}})) {
  311. $error .= "<li>Account with email address $_data{'email'} already exits</li>";
  312. }
  313. dbmclose(%_ACCTS);
  314.  
  315. if(&pit($_data{'email'})) {
  316. $error .= "<li>Invalid Email Address</li>"
  317. if $_data{'email'} !~ m/\@.+\./;
  318. } else {
  319. $error .= "<li>Missing email address</li>";
  320. }
  321.  
  322. $error .= "<li>Missing Password</li>" unless &pit($_data{'password'});
  323. $error .= "<li>Missing Confirmation Password</li>" unless &pit($_data{'confirmpassword'});
  324.  
  325. if($_data{'password'} ne $_data{'confirmpassword'}) {
  326. $error .= "<li>Two passwords are different</li>";
  327. }
  328.  
  329. $error .= "<li>Missing First Name</li>" unless &pit($_data{'firstname'});
  330. $error .= "<li>Missing Last Name</li>" unless &pit($_data{'lastname'});
  331. $error .= "<li>Missing Address</li>" unless &pit($_data{'address'});
  332. $error .= "<li>Missing City</li>" unless &pit($_data{'city'});
  333. $error .= "<li>Missing State</li>" unless &pit($_data{'state'});
  334. if(&pit($_data{'state'})) {
  335. $error .= "<li>Invalid State</li>" if $_data{'state'} !~ m/^[a-zA-Z]{2}/;
  336. }
  337.  
  338. if(&pit($_data{'zip'})) {
  339. $error .= "<li>Invalid Zip</li>" if $_data{'zip'} !~ m/^\d{5,}/;
  340. } else {
  341. $error .= "<li>Missing Zip</li>";
  342. }
  343.  
  344. return $error;
  345.  
  346. }
  347.  
  348. sub createAccount {
  349. my($q, %_info) = @_;
  350. my(%_ACCTS);
  351. dbmopen(%_ACCTS, "${dbPath}.accounts", 0664)
  352. || &error("createAccount", $q, "Can't modify accounts database");
  353. $_ACCTS{"\L$_info{'email'}"} = $_info{'password'};
  354. dbmclose(%_ACCTS);
  355. dbmopen(%_ACCTS, "${dbPath}$_info{'email'}", 0664)
  356. || &error("createAccount", $q, "Can't create account database for $_infp{'email'}");
  357. $_ACCTS{'firstname'} = $_info{'firstname'};
  358. $_ACCTS{'lastname'} = $_info{'lastname'};
  359. $_ACCTS{'address'} = $_info{'address'};
  360. $_ACCTS{'address2'} = $_info{'address2'};
  361. $_ACCTS{'city'} = $_info{'city'};
  362. $_ACCTS{'state'} = $_info{'state'};
  363. $_ACCTS{'zip'} = $_info{'zip'};
  364. $_ACCTS{'sweepstake'} = $_info{'sweepstake'};
  365. $_ACCTS{'info'} = $_info{'info'};
  366. $_ACCTS{'age'} = $_info{'age'};
  367. dbmclose(%_ACCTS);
  368. }
  369.  
  370. sub recordSweepStake {
  371. my(%_info) = @_;
  372.  
  373. my($dataFile) = "${dbPath}sweepstake.xls";
  374. if(-e $dataFile) {
  375. open(OUTPUT, ">>$dataFile") || die "can't append to file $dataFile\n";
  376. } else {
  377. open(OUTPUT, ">$dataFile") || die "can't append to file $dataFile\n";
  378. print OUTPUT "First Name\tLast Name\tAddress\tAddress 2\tCity\tState\tZip\tE-mail\tGet Info\n";
  379. }
  380. print OUTPUT "$_info{firstname}\t$_info{lastname}\t$_info{address1}\t$_info{address2}\t$_info{city}\t$_info{state}\t$_info{zip}\t$_info{info}\n";
  381. close(OUTPUT);
  382. return;
  383. }
  384.  
  385. sub mailSanta {
  386. my($q, $u, %d) = @_;
  387. my(%U, %PRODUCTS, @products, %LISTS, $p, $fname);
  388.  
  389. dbmopen(%U, "$dbPath$u", undef)
  390. || &error("mailSanta", $q, "Can't read user info for $u");
  391. $fname = $U{'firstname'};
  392. dbmclose(%U);
  393. open(MAIL, "|$mailprog -t -f$u") || die "cannot send email\n";
  394. print MAIL "To: $d{'email'}\n";
  395. print MAIL "Subject: YOU'RE SOMEBODY'S SPECIAL SANTA\n\n";
  396. print MAIL "YOU'RE SOMEBODY'S SPECIAL SANTA\n\n";
  397. print MAIL "Hey $d{'santa'}, $fname has chosen YOU as a special Santa this year.\n\n";
  398. print MAIL "\"That's great\", you might be saying, \"but I don't know what to get!\" Well, $fname has made it easy by creating a Sony Wishlist for you to choose from. It's filled with cool Sony stuff $fname would love to find under the tree.\n\n";
  399.  
  400. $d{'list'} =~ s/ /%20/g;
  401. $d{'santa'} =~ s/ /%20/g;
  402. print MAIL "Ready to see the list $fname created? Just click below:\n\n";
  403. print MAIL "http://63.224.30.26$ENV{'SCRIPT_NAME'}?action=santa&u=$u&l=$d{'list'}&s=$d{'santa'}\n\n";
  404.  
  405. print MAIL "GET A FREE GIFT FROM SONYSTYLE.COM\n";
  406. print MAIL "We at Sonystyle.com are doing our part to make your holiday shopping easy, too! When you spend \$300 on items found on the Wishlist, you'll get a free thank you gift from Sony.\n\n";
  407.  
  408. print MAIL "To get your free gift, click below to download a special coupon:\n";
  409. print MAIL "http://promo.iq.com/common/e.jsp?vgid=22927&p=DI&e=1&ref=IQREPLACETEXT\n\n";
  410.  
  411. print MAIL "So make $fname happy, and you'll receive a free thank you gift from Sony for being such a good Santa.\n\n";
  412.  
  413. print MAIL "Happy Holidays from $fname, Sony, and Sonystyle.com!\n\n";
  414. close(MAIL);
  415.  
  416. open(MSG, ">$dbPath$u.$d{'list'}$d{'santa'}.txt")
  417. || &error("mailSanta", $q, "Can't save message to $d{'santa'} from $u with list $d{'list'}");
  418. $d{'message'} =~ s/\n/<br>/g;
  419. print MSG "$d{'message'}\n";
  420. close(MSG);
  421. #print MAIL "------------------------------------------------------------\n";
  422. #dbmopen(%LISTS, "$dbPath$u.lists", undef)
  423. #|| &error("mailSanta", $q, "Can't read from lists for $u");
  424. #@products = split(/ # /, $LISTS{$d{'list'}});
  425. #dbmclose(%LISTS);
  426. #dbmopen(%PRODUCTS, "${dbPath}.products", undef)
  427. #|| &error("mailSanta", $q, "Can't read product lists");
  428. #foreach $p (@products) {
  429. #my($price, $name) = split(/ # /, $PRODUCTS{$p});
  430. #print MAIL "$p\t\t\$$price\t\t$name\n";
  431. #}
  432. #dbmclose(%PRODUCTS);
  433. #print MAIL "------------------------------------------------------------\n";
  434. }
  435.  
  436. sub error {
  437. my($q, $_where, $_msg) = @_;
  438.  
  439. my(%d);
  440. $d{'where'} = $_where;
  441. $d{'msg'} = $_msg;
  442.  
  443. &showPage("${templatePath}error.html", $q, "", "content", %d);
  444. exit 0;
  445. }
  446.  
  447. sub showSanta {
  448. my($q, $u, $l, $s) = @_;
  449. my(%detail, %L, %U, @products);
  450.  
  451. $detail{'message'} = "Dear $s:<br><br>";
  452. $l =~ s/ /%20/g;
  453. $s =~ s/ /%20/g;
  454. open(MSG, "$dbPath$u.$l$s.txt")
  455. || &error("showSanta", $q, "Can't read message to $s from $u with list $l");
  456. while(<MSG>) {
  457. $detail{'message'} .= $_
  458. }
  459. close(MSG);
  460. dbmopen(%U, "$dbPath$u", undef) || &error("showSanta", $q, "can't read user information for $u");
  461. $detail{'message'} .= "<br><br>From $U{'firstname'} $U{'lastname'}";
  462. dbmclose(%U);
  463. &showPage("${templatePath}santa.head.html", $q, "content", %detail);
  464.  
  465. $l =~ s/%20/ /g;
  466. dbmopen(%L, "$dbPath$u.lists", undef) || &error("showSanta", $q, "can't read list content for $u");
  467. @products = split(/ # /, $L{$l});
  468. dbmclose(%L);
  469.  
  470. dbmopen(%L, "${dbPath}.products", undef) || &error("showSanta", $q, "can't read products");
  471.  
  472. $detail{i} = 1;
  473. foreach $content (@products) {
  474. $detail{'img'} = $detail{'model'} = $content;
  475. ($detail{'id'}, $detail{'price'}, $detail{'name'}, $detail{'link'}) = split(/ # /, $L{$content});
  476. $detail{'price'} = "\$$detail{'price'}";
  477. if($detail{'link'} =~ /\/(\w+)\.html/) {
  478. $detail{'link'} = "$`/productinfo/${1}2.html";
  479. }
  480. $detail{'img'} =~ s/\///g;
  481. &showPage("${templatePath}santa.loop.html", $q, "", %detail);
  482. $detail{i}++;
  483. }
  484. dbmclose(%L);
  485.  
  486.  
  487. &showPage("${templatePath}santa.foot.html", $q, "", %detail);
  488. }
  489.  
  490. sub showPage {
  491. my($template, $q, $content, %Form) = @_;
  492. my(@input, $i);
  493. local(*_MYINPUT);
  494.  
  495. if($content) {
  496. print "Content-type: text/html\n\n";
  497. }
  498.  
  499. open(_MYINPUT, $template) || die "can't read from $template\n";
  500. while(<_MYINPUT>) {
  501. $input[$i] = $_;
  502. $i++;
  503. }
  504. close(_MYINPUT);
  505.  
  506. for($i=0; $i<@input; $i++) {
  507. &processLine($input[$i], %Form);
  508. }
  509. }
  510.  
  511. sub processLine {
  512. my($inputline, %Form) = @_;
  513. my($condition, $then, $else, $line);
  514. my($begin, $end, $pitline);
  515.  
  516. $inputline =~ s/REPLACEME/$wishlistHome/g;
  517. if ($inputline =~ m/<!--%(.+)%-->/) {
  518. $begin = $`;
  519. $end = $';
  520. $pitline = $1;
  521. if ($pitline =~ /\? (.*)::/) {
  522. $condition = $`;
  523. $then = $1;
  524. $else = $';
  525. } elsif ($pitline =~ /\? /) {
  526. $condition = $`;
  527. $then = $';
  528. }
  529.  
  530. if ($condition) {
  531. $condition = &pit($condition);
  532. $then = &pit($then);
  533. $else = &pit($else) if $else;
  534. if (&evalCond($condition, %Form)) {
  535. $line = $then;
  536. } elsif ($else) {
  537. $line = $else;
  538. }
  539.  
  540. $line =~ s/\$((\w|\d|-)+)/$Form{$1}/g;
  541. print "$begin$line$end";
  542. } else {
  543. $pitline = &pit($pitline);
  544. $pitline =~ s/\$((\w|\d|-)+)/$Form{$1}/g;
  545. print "$begin$pitline$end";
  546. }
  547. } else {
  548. print $inputline;
  549. }
  550. }
  551.  
  552. sub evalCond {
  553. my($condition, %Form) = @_;
  554. my(@temp, $index);
  555.  
  556. @temp = split(/ /, $condition);
  557. for($index=0; $temp[$index]; $index++) {
  558. $temp[$index] =~ s/\$((\w|\d|-)+)/\$Form{'$1'}/g;
  559. }
  560. $condition = join(" ", @temp);
  561.  
  562. return eval $condition;
  563. }
  564.  
  565. sub pit {
  566. local($pit) = @_;
  567. $pit =~ s/^\s*(.*?)\s*$/$1/;
  568. return $pit;
  569. }
RAW Paste Data