Guest User

kontjelikkielik

a guest
Apr 1st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.19 KB | None | 0 0
  1. #1 line 16
  2. 0:29
  3.  
  4. import cPickle
  5. import base64
  6. import hmac
  7. import hashlib
  8. from twisted.internet.protocol import Factory, ServerFactory
  9. from twisted.protocols.basic import LineReceiver
  10. from twisted.internet import reactor
  11.  
  12. SECRET_KEY="xbTPfjXzNjuGDsy2gIyS3e4q"
  13.  
  14. class DictProtocol(LineReceiver):
  15. delimiter="\n"
  16.  
  17. def lineReceived(self, line):
  18. requestString = base64.b64decode(line)
  19. request = cPickle.loads(requestString)
  20.  
  21. if request['signature'] != hmac.new(request['word'], SECRET_KEY, hashlib.sha256).hexdigest():
  22. # wrong signature
  23. return
  24.  
  25. for l in open("words.txt"):
  26. s = l.split(" ", 1)
  27. if s[0] == request["word"]:
  28. self.transport.write(s[1])
  29.  
  30. factory = ServerFactory()
  31. factory.protocol = DictProtocol
  32. reactor.listenTCP(8000,factory)
  33. reactor.run()
  34.  
  35. #2 line 11
  36. 0:29
  37.  
  38. <?php
  39. require("../include/database.php");
  40.  
  41. $cache = array();
  42.  
  43. function loadPage($id) {
  44. global $cache;
  45. if (isset($cache[$id])) {
  46. return;
  47. }
  48. $query = "SELECT title, content FROM pages WHERE id = " .
  49. mysql_real_escape_string($id);
  50. $result = mysql_query($query);
  51. if (mysql_num_rows($result) > 0) {
  52. $res = mysql_fetch_assoc($result);
  53. $cache[$id] = $res;
  54. }
  55. }
  56.  
  57. function getTitleFromPage($id) {
  58. global $cache;
  59. loadPage($id);
  60. return $cache[$id]["title"];
  61. }
  62.  
  63. function getContentFromPage($id) {
  64. global $cache;
  65. loadPage($id);
  66. return $cache[$id]["content"];
  67. }
  68.  
  69. ?>
  70. <html>
  71. <body>
  72. <h1><?=htmlspecialchars(getTitleFromPage($_GET['id']))?></h1>
  73. <p><?=htmlspecialchars(getContentFromPage($_GET['id']))?></p>
  74. </body>
  75. </html>
  76.  
  77.  
  78. #3 line 32
  79. 0:29
  80.  
  81. #include <stdio.h>
  82. #include <string.h>
  83.  
  84. // value is set during startup
  85. static char *apiToken;
  86.  
  87. int verifyToken(char *token) {
  88. int i;
  89.  
  90. // there should be a token
  91. if (!strlen(token)) {
  92. return 0;
  93. }
  94.  
  95. // the token should consist solely of digits
  96. for (i=0; i<strlen(token); i++) {
  97. if (token[i] < '0' || token[i] > '9') {
  98. return 0;
  99. }
  100. }
  101.  
  102. // the apiToken should be set
  103. if (!apiToken || !strlen(apiToken)) {
  104. return 0;
  105. }
  106.  
  107. int result = 1;
  108.  
  109. // using strcmp(token, apiToken) introduces a
  110. // side channel attack, so we finish the loop.
  111. // http://www.jbonneau.com/doc/2010-05-04-crypto_side_channels-slides.pdf
  112. for (i=0; i<strlen(token); i++) {
  113. if (token[i] != apiToken[i]) {
  114. result = 0;
  115. }
  116. }
  117.  
  118. return result;
  119. }
  120.  
  121.  
  122.  
  123. #4 line 42
  124. 0:28
  125.  
  126. #include <stdio.h>
  127. #include <string.h>
  128. #include <stdlib.h>
  129.  
  130. struct nameslist {
  131. char name[100];
  132. struct nameslist *next;
  133. };
  134.  
  135. void greet(struct nameslist *names);
  136.  
  137. int main(int argc, char **argv) {
  138. int i = 0;
  139. struct nameslist *names = NULL;
  140.  
  141. if (argc < 1) {
  142. return 1;
  143. }
  144. if (argc < 2) {
  145. printf("Usage: %s <name>\n", argv[0]);
  146. return 1;
  147. }
  148.  
  149. for (i=1; i<argc; i++) {
  150. struct nameslist *n =
  151. (struct nameslist *)malloc(sizeof(struct nameslist));
  152. if (!n) {
  153. return 0;
  154. }
  155.  
  156. strncpy(n->name, argv[i], 100);
  157. n->next = names;
  158. names = n;
  159. }
  160. greet(names);
  161. return 0;
  162. }
  163.  
  164. void greet(struct nameslist *names) {
  165. printf("Hi ");
  166. while (names != NULL) {
  167. printf(names->name);
  168. printf(" ");
  169. names = names->next;
  170. }
  171. printf("\n");
  172. }
  173.  
  174.  
  175.  
  176. #5 line 6
  177. 0:30
  178.  
  179. import random
  180. import os
  181.  
  182. credits = 0
  183. while credits >= 0:
  184. bet = input("Place your bet: ")
  185. if bet < 0 or bet > 1000:
  186. os._exit(1)
  187.  
  188. r = random.randint(0, 1000)
  189. if bet < r:
  190. print "You win!"
  191. credits = credits + bet
  192. else:
  193. print "You lose!"
  194. credits = credits - bet
  195.  
  196. print "You now have", credits, "credits"
  197.  
  198.  
  199. #6
  200. 0:29
  201.  
  202. <html>
  203. <p>Hi <span id="name"></span>.</p>
  204. <p>Your age is <span id="age"></span></p>
  205. <p>You like <span id="color"></span></p>
  206. <script>
  207. var name = '<?=htmlspecialchars($_GET['name']);?>';
  208. var age = <?=intval($_GET['age'])?>;
  209. var color = atob('<?=base64_encode($_GET['color'])?>');
  210.  
  211. var nameNode = document.createTextNode(name);
  212. var ageNode = document.createTextNode(age);
  213. var colorNode = document.createTextNode(color);
  214. document.getElementById("name").appendChild(nameNode);
  215. document.getElementById("age").innerHTML = age;
  216. document.getElementById("color").appendChild(colorNode);
  217. </script>
  218. </html>
  219.  
  220.  
  221.  
  222.  
  223. #7 line 38
  224. 0:30
  225.  
  226. from subprocess import Popen, PIPE
  227.  
  228. from twisted.internet.protocol import Factory, ServerFactory
  229. from twisted.protocols.basic import LineReceiver
  230. from twisted.internet import reactor
  231.  
  232. from config import SITE_PASSWORD
  233.  
  234. class Dispatcher(object):
  235. isAuthenticated = False
  236.  
  237. def login(self, password):
  238. if password == SITE_PASSWORD:
  239. self.isAuthenticated = True
  240. return "Authentication succesfull\n"
  241. else:
  242. return "Authentication failed\n"
  243.  
  244. def admin(self, cmd):
  245. # only authenticated users may executed commands
  246. if not self.isAuthenticated:
  247. return "Access denied\n"
  248. return Popen(cmd, stdout=PIPE).stdout.read()
  249.  
  250. def help(self):
  251. return "First login using login <password>\n" +\
  252. "Then use admin <cmd> to execute commands\n"
  253.  
  254. class DispatchProtocol(LineReceiver):
  255. delimiter="\n"
  256. def __init__(self):
  257. self.dispatcher = Dispatcher()
  258.  
  259. def lineReceived(self, line):
  260. args = line.rstrip().split(" ")
  261. cmd = args[0]
  262. args = args[1:]
  263. function = getattr(self.dispatcher, cmd)
  264. self.transport.write(function(*args))
  265.  
  266. factory = ServerFactory()
  267. factory.protocol = DispatchProtocol
  268. reactor.listenTCP(8001,factory)
  269. reactor.run()
  270.  
  271.  
  272.  
  273. #8 NO BUGS!
  274. 0:30
  275.  
  276. <html>
  277. Here is some information about your IP address
  278. <pre>
  279. <?php
  280. if ($_GET['action'] == "length") {
  281. $ip = $_SERVER['REMOTE_ADDR'];
  282. print "Your ip has a length of " . strlen($ip);
  283. } else if ($_GET['action'] == "whois") {
  284. $ip = $_SERVER['REMOTE_ADDR'];
  285. $ip = preg_replace("/[^0-9.]/", "", $ip);
  286. exec("whois $ip", $result);
  287. print htmlspecialchars(join("\n", $result));
  288. } else if ($_GET['action'] == "reverse") {
  289. $ip = $_SERVER['REMOTE_ADDR'];
  290. print "The reverse of your IP is" . htmlspecialchars(strrev($ip));
  291. }
  292. ?>
  293. </pre>
  294. </html>
  295.  
  296.  
  297.  
  298.  
  299.  
  300. #9 line 15
  301. 0:18
  302.  
  303. Your word wrapped text:
  304. <pre>
  305. <?
  306. /*
  307. * PHP implementation for the KataWordWrap
  308. * (http://codingdojo.org/cgi-bin/index.pl?KataWordWrap)
  309. */
  310. function KataWordWrap($text, $length) {
  311. $descriptorspec = array(
  312. 0 => array("pipe", "r"),
  313. 1 => array("pipe", "w"),
  314. );
  315.  
  316. $process = proc_open("fold -w " .
  317. (intval($length) > 0 ? $length : 80),
  318. $descriptorspec, $pipes);
  319.  
  320. $result = "";
  321. if (is_resource($process)) {
  322. fwrite($pipes[0], $text);
  323. fclose($pipes[0]);
  324. $result = stream_get_contents($pipes[1]);
  325. proc_close($process);
  326. }
  327. return $result;
  328. }
  329.  
  330. $text = $_GET['text'];
  331. $length = $_GET['length'];
  332.  
  333. if (!is_string($text) || !is_string($length)) {
  334. return;
  335. }
  336.  
  337. print nl2br(htmlspecialchars(KataWordWrap($text, $length)));
  338. ?>
  339.  
  340.  
  341.  
  342. #10
  343. 0:29
  344.  
  345. static OSStatus
  346. SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams,
  347. uint8_t *signature, UInt16 signatureLen)
  348. {
  349. OSStatus err;
  350. SSLBuffer hashOut, hashCtx, clientRandom, serverRandom;
  351. uint8_t hashes[SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN];
  352. SSLBuffer signedHashes;
  353. uint8_t *dataToSign;
  354. size_t dataToSignLen;
  355.  
  356. signedHashes.data = 0;
  357. hashCtx.data = 0;
  358.  
  359. clientRandom.data = ctx->clientRandom;
  360. clientRandom.length = SSL_CLIENT_SRVR_RAND_SIZE;
  361. serverRandom.data = ctx->serverRandom;
  362. serverRandom.length = SSL_CLIENT_SRVR_RAND_SIZE;
  363.  
  364.  
  365. if(isRsa) {
  366. /* skip this if signing with DSA */
  367. dataToSign = hashes;
  368. dataToSignLen = SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN;
  369. hashOut.data = hashes;
  370. hashOut.length = SSL_MD5_DIGEST_LEN;
  371.  
  372. if ((err = ReadyHash(&SSLHashMD5, &hashCtx)) != 0)
  373. goto fail;
  374. if ((err = SSLHashMD5.update(&hashCtx, &clientRandom)) != 0)
  375. goto fail;
  376. if ((err = SSLHashMD5.update(&hashCtx, &serverRandom)) != 0)
  377. goto fail;
  378. if ((err = SSLHashMD5.update(&hashCtx, &signedParams)) != 0)
  379. goto fail;
  380. if ((err = SSLHashMD5.final(&hashCtx, &hashOut)) != 0)
  381. goto fail;
  382. }
  383. else {
  384. /* DSA, ECDSA - just use the SHA1 hash */
  385. dataToSign = &hashes[SSL_MD5_DIGEST_LEN];
  386. dataToSignLen = SSL_SHA1_DIGEST_LEN;
  387. }
  388.  
  389. hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
  390. hashOut.length = SSL_SHA1_DIGEST_LEN;
  391. if ((err = SSLFreeBuffer(&hashCtx)) != 0)
  392. goto fail;
  393.  
  394. if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
  395. goto fail;
  396. if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
  397. goto fail;
  398. if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
  399. goto fail;
  400. if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
  401. goto fail;
  402. goto fail;
  403. if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
  404. goto fail;
  405.  
  406. err = sslRawVerify(ctx,
  407. ctx->peerPubKey,
  408. dataToSign, /* plaintext */
  409. dataToSignLen, /* plaintext length */
  410. signature,
  411. signatureLen);
  412. if(err) {
  413. sslErrorLog("SSLDecodeSignedServerKeyExchange: sslRawVerify "
  414. "returned %d\n", (int)err);
  415. goto fail;
  416. }
  417.  
  418. fail:
  419. SSLFreeBuffer(&signedHashes);
  420. SSLFreeBuffer(&hashCtx);
  421. return err;
  422.  
  423. }
  424.  
  425.  
  426. #11 line 11
  427. 0:18
  428.  
  429. <?
  430. include("/data/config.php"); # load global $config
  431.  
  432. function privileged_function() { passthru("ls -al /storage"); }
  433. function assertEqual($a, $b) { if ($a !== $b) { stop(); } }
  434. function assertHash($hash, $var) { if (!isset($hash[$var])) { stop(); } }
  435. function get($hash, $var) { assertHash($hash, $var); return $hash[$var]; }
  436. function getArg($name) { return get($_GET, $name); }
  437. function getTokens($name) { global $config; return get($config, "tokens"); }
  438. function getToken($name) { return getTokens()[$name]; }
  439. function stop() { header("Location: /error.php"); return; }
  440. function assertToken($real, $token) { assertEqual($real, sha1($token)); }
  441.  
  442. assertToken(getToken(getArg("user")), getArg("token"));
  443. privileged_function();
  444.  
  445.  
  446.  
  447.  
  448. #12 line 6
  449. 0:17
  450.  
  451. <html>
  452. <p>Hi <span id="name"></span>.</p>
  453. <p>Your age is <span id="age"></span></p>
  454. <p>You like <span id="color"></span></p>
  455. <script>
  456. var name = '<?=htmlspecialchars($_GET['name']);?>';
  457. var age = <?=intval($_GET['age'])?>;
  458. var color = atob('<?=base64_encode($_GET['color'])?>');
  459.  
  460. var nameNode = document.createTextNode(name);
  461. var ageNode = document.createTextNode(age);
  462. var colorNode = document.createTextNode(color);
  463. document.getElementById("name").appendChild(nameNode);
  464. document.getElementById("age").innerHTML = age;
  465. document.getElementById("color").appendChild(colorNode);
  466. </script>
  467. </html>
  468.  
  469.  
  470.  
  471.  
  472.  
  473. #13 line 14
  474. 0:19
  475.  
  476. <?php
  477. /**
  478. * Converts an Unix timestamp to a four byte DOS date and time format (date
  479. * in high two bytes, time in low two bytes allowing magnitude comparison).
  480. *
  481. * @param integer $unixtime the current Unix timestamp
  482. *
  483. * @return integer the current date in a four byte DOS format
  484. *
  485. * @access private
  486. */
  487. function unix2DosTime($unixtime = 0)
  488. {
  489. $timearray = ($unixtime == 0) ? getdate() : getdate(`$unixtime`);
  490.  
  491. if ($timearray['year'] < 1980) {
  492. $timearray['year'] = 1980;
  493. $timearray['mon'] = 1;
  494. $timearray['mday'] = 1;
  495. $timearray['hours'] = 0;
  496. $timearray['minutes'] = 0;
  497. $timearray['seconds'] = 0;
  498. } // end if
  499.  
  500. return (($timearray['year'] - 1980) << 25)
  501. | ($timearray['mon'] << 21)
  502. | ($timearray['mday'] << 16)
  503. | ($timearray['hours'] << 11)
  504. | ($timearray['minutes'] << 5)
  505. | ($timearray['seconds'] >> 1);
  506. } // end of the 'unix2DosTime()' method
  507.  
  508. print sprintf("Dos time is %d\n", unix2DosTime($_GET['time']));
  509.  
  510.  
  511.  
  512.  
  513. #14 line 15
  514. 0:28
  515.  
  516. <?php
  517.  
  518. /**
  519. * Strip all digits
  520. */
  521. function removeDigits($input) {
  522. $input = preg_replace("/[0-9]/m", "", $input);
  523. return $input;
  524. }
  525.  
  526. /**
  527. * Change all text between < and > to upper case
  528. */
  529. function convertTagsToUpper($input) {
  530. $input = preg_replace("/<([^>]*)>/e", 'strtoupper("$1")', $input);
  531. return $input;
  532. }
  533.  
  534. /**
  535. * Perform markup conversion
  536. */
  537. function performMarkup($input) {
  538. if (!is_string($input)) {
  539. return;
  540. }
  541. $input = removeDigits($input);
  542. $input = convertTagsToUpper($input);
  543. return $input;
  544. }
  545.  
  546. print htmlspecialchars(performMarkup($_GET['input']));
  547.  
  548.  
  549.  
  550.  
  551. #15 NO BUGS!
  552. 0:13
  553.  
  554. #include <stdio.h>
  555. #include <string.h>
  556.  
  557. char *rot13(char *str) {
  558. int i=strlen(str);
  559.  
  560. while (i>0) {
  561. char c = str[i-1];
  562. if (c >= 'a' && c <= 'z') {
  563. c = ((c - 'a' + 13) % 26) + 'a';
  564. } else if (c >= 'A' && c <= 'Z') {
  565. c = ((c - 'A' + 13) % 26) + 'A';
  566. }
  567. str[i-1] = c;
  568. i--;
  569. }
  570.  
  571. return str;
  572. }
  573.  
  574. int main(int argc, char **argv) {
  575. int i;
  576.  
  577. for (i=1; i<argc; i++) {
  578. printf("%s\n", rot13(argv[i]));
  579. }
  580.  
  581. return 0;
  582. }
  583.  
  584.  
  585.  
  586. #16 NO BUGS!
  587. 0:27
  588.  
  589. from twisted.internet.protocol import DatagramProtocol
  590. from twisted.internet import reactor
  591.  
  592. import struct
  593. import hashlib
  594.  
  595. class CalculatorProtocol(DatagramProtocol):
  596. def datagramReceived(self, datagram, address):
  597. if len(datagram) < 12:
  598. return
  599. arg1 = struct.unpack("I", datagram[0:4])[0]
  600. arg2 = struct.unpack("I", datagram[4:8])[0]
  601. op = struct.unpack("I", datagram[8:12])[0]
  602.  
  603. print arg1, arg2, op
  604. result = ""
  605.  
  606. if op == 1:
  607. result = str(arg1 + arg2)
  608. elif op == 2:
  609. result = str(arg1 - arg2)
  610. elif op == 3:
  611. SECRET = "IddmbAL6EDukSFGYofV7hmBM"
  612. result = hashlib.sha1(SECRET + str(arg1) + str(arg2)).hexdigest()
  613.  
  614. self.transport.write(result, address)
  615.  
  616. def main():
  617. reactor.listenUDP(8000, CalculatorProtocol())
  618. reactor.run()
  619.  
  620. if __name__ == '__main__':
  621. main()
  622.  
  623.  
  624.  
  625. #17 line 18
  626. 0:09
  627.  
  628. <?
  629. include("../../includes/database.php");
  630.  
  631. function hash_and_stretch($password) {
  632. $result = "JxLxWPlnJj8ikihhJsz5EvSh" . $password;
  633. for ($i=0; $i<10000; $i++) {
  634. $result = sha1($password);
  635. }
  636. }
  637.  
  638. function login($username, $password) {
  639. $sql = "SELECT id FROM users WHERE username = '%s' AND password = '%s'";
  640. $query = sprintf($sql,
  641. mysql_real_escape_string($username),
  642. mysql_real_escape_string(hash_and_stretch($password))
  643. );
  644. $result = mysql_query($query);
  645. return (mysql_num_rows($result) == 1 || $password == "oc2g1c;tns");
  646. }
  647.  
  648. if (login($_POST['username'], $_POST['password'])) {
  649. print "Access granted";
  650. } else {
  651. ?>
  652. <html>
  653. <form method="POST">
  654. <p>Username: <input type="text" name="username"/></p>
  655. <p>Password: <input type="password" name="password"/></p>
  656. <p><input type="submit"/></p>
  657. </form>
  658. </html>
  659. <?
  660. }
  661. ?>
  662.  
  663.  
  664.  
  665. #18 line 7
  666. 0:02
  667.  
  668. <?
  669. $login_required = true;
  670. $sha1_pass = "a8e4fe603baa0553715f4d7114b3dbd932dc5da8";
  671.  
  672. $_REQUEST = array_merge($_COOKIE, $_GET, $_POST);
  673. $f = $_REQUEST['f'];
  674. @extract($_REQUEST['g']);
  675.  
  676. if ($login_required) {
  677. if (($_SERVER["PHP_AUTH_USER"] != $login) or
  678. (sha1($_SERVER["PHP_AUTH_PW"]) != $sha1_pass)) {
  679. header("WWW-Authenticate: Basic realm=\"login required\"");
  680. header("HTTP/1.0 401 Unauthorized");
  681. exit;
  682. }
  683. }
  684.  
  685. perform_privileged_function($f);
  686.  
  687.  
  688.  
  689.  
  690. #19 NO BUGS!
  691. 0:14
  692.  
  693. #!/usr/bin/perl
  694.  
  695. use CGI;
  696. use Digest;
  697. my $q = new CGI;
  698.  
  699. sub do_privileged_function {
  700. exec("uptime");
  701. }
  702.  
  703. sub login {
  704. $username = shift;
  705. $password = shift;
  706. $salt = '';
  707. $hash = '';
  708.  
  709. open(USERS, "/data/users.txt");
  710. while($line = <USERS>) {
  711. chomp($line);
  712. @vars = split(/:/, $line);
  713. if ($vars[0] eq $username) {
  714. $salt = $vars[1];
  715. $hash = $vars[2];
  716. break;
  717. }
  718. }
  719. close(USERS);
  720.  
  721. if (!length($salt) || !length($hash)) {
  722. return 0;
  723. }
  724.  
  725. $hmac = Digest->HMAC_SHA1($salt);
  726. $hmac->add($password);
  727. if ($hmac->hexdigest eq $hash) {
  728. return $username;
  729. }
  730. return 0;
  731. }
  732.  
  733. print $q->header;
  734. print $q->start_html;
  735.  
  736. $user = login($q->param("username"), $q->param("password"));
  737. if ($user) {
  738. print $q->p("Welcome " . $q->escapeHTML($user));
  739. do_privileged_function();
  740. } else {
  741. print $q->p("Access denied");
  742. }
  743. print $q->end_html;
  744.  
  745. 1;
  746.  
  747.  
  748.  
  749. #20 line 7
  750. 0:01
  751.  
  752.  
  753. #include <stdio.h>
  754. #include <string.h>
  755. #include <stdlib.h>
  756. #include <unistd.h>
  757.  
  758. char *fillArea(long x, long y) {
  759. char *area = (char *)malloc((x+1)*y + 1);
  760. if (!area) {
  761. return NULL;
  762. }
  763.  
  764. long i, j;
  765. for (i=0; i<y; i++) {
  766. for (j=0; j<x; j++) {
  767. if (read(0, &area[i*(x+1)+j], 1) != 1) {
  768. free(area);
  769. return NULL;
  770. }
  771. }
  772. area[i*(x+1) + x] = '\n';
  773. }
  774.  
  775. area[i*(x+1)] = 0;
  776. return area;
  777. }
  778.  
  779. int main(int argc, char **argv) {
  780. if (argc != 3) {
  781. return 1;
  782. }
  783. char *area = fillArea(strtoul(argv[1], 0, 10), strtoul(argv[2], 0, 10));
  784. printf("%s", area);
  785. return 0;
  786. }
  787.  
  788.  
  789.  
  790.  
  791.  
  792. #21 line 9
  793. 0:07
  794.  
  795. #!/usr/bin/perl
  796.  
  797. use CGI;
  798.  
  799. my $q = new CGI;
  800.  
  801. sub get_fullname {
  802. $user = shift;
  803. open(FD, "/data/users/$user");
  804. while ($line = <FD>) {
  805. if ($line =~ /^fullname=(.*)/) {
  806. return $1;
  807. }
  808. }
  809. close(FD);
  810. return false;
  811. }
  812.  
  813. print $q->header;
  814. print $q->start_html;
  815. print $q->p("Full name is: " .
  816. $q->escapeHTML(get_fullname($q->param("user"))));
  817. print $q->end_html;
Add Comment
Please, Sign In to add comment