Guest User

Untitled

a guest
Jun 15th, 2011
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. <?php
  2.  
  3. require 'PHProxy.class.php';
  4.  
  5. $config = array
  6. (
  7. 'url_var_name' => 'q',
  8. 'flags_var_name' => 'hl',
  9. 'get_form_name' => '__script_get_form',
  10. 'proxy_url_form_name' => 'poxy_url_form',
  11. 'proxy_settings_form_name' => 'poxy_settings_form',
  12. 'max_file_size' => -1
  13. );
  14.  
  15. $flags = 'prev';
  16.  
  17. if (isset($_GET[$config['flags_var_name']]))
  18. {
  19. $flags = $_GET[$config['flags_var_name']];
  20. }
  21.  
  22. $PHProxy = & new PHProxy($config, $flags);
  23.  
  24. if (isset($_GET[$PHProxy->config['get_form_name']]))
  25. {
  26. $url = decode_url($_GET[$PHProxy->config['get_form_name']]);
  27. $qstr = preg_match('#\?#', $url) ? (strpos($url, '?') === strlen($url) ? '' : '&') : '?';
  28. $arr = explode('&', $_SERVER['QUERY_STRING']);
  29. if (preg_match('#^'.$PHProxy->config['get_form_name'].'#', $arr[0]))
  30. {
  31. array_shift($arr);
  32. }
  33. $url .= $qstr . implode('&', $arr);
  34. $PHProxy->start_transfer(encode_url($url));
  35. echo $PHProxy->return_response();
  36. exit();
  37. }
  38.  
  39. if (isset($_GET[$PHProxy->config['url_var_name']]))
  40. {
  41. $PHProxy->start_transfer($_GET[$PHProxy->config['url_var_name']]);
  42. echo $PHProxy->return_response();
  43. exit();
  44. }
  45.  
  46. if (isset($_GET['action'], $_GET['delete']) && $_GET['action'] == 'cookies')
  47. {
  48. $PHProxy->delete_cookies($_GET['delete']);
  49. header("Location: $PHProxy->script_url?action=cookies");
  50. exit();
  51. }
  52.  
  53. if (isset($_POST['username'], $_POST['password'], $_POST['server'], $_POST['realm'], $_POST['auth_url']))
  54. {
  55. $PHProxy->request_method = 'GET';
  56. $PHProxy->url_segments['host'] = decode_url($_POST['server']);
  57. $PHProxy->set_authorization($_POST['username'], $_POST['password']);
  58. $PHProxy->start_transfer($_POST['auth_url']);
  59. echo $PHProxy->return_response();
  60. exit();
  61. }
  62. ?>
  63. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  64. <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
  65. <head>
  66. <title>PHProxy</title>
  67. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  68. <link rel="stylesheet" type="text/css" href="style.css" media="all" />
  69. <script src="javascript.js" type="text/javascript"></script>
  70. <script type="text/javascript" language="javascript">
  71. function focusURL() {
  72. document.getElementById("url").focus();
  73. }
  74. </script>
  75. </head>
  76. <body onload="focusURL();">
  77. <div id="container">
  78. <div id="menu">
  79. <a href="<?php echo $_SERVER['PHP_SELF'] ?>">URL Form</a> |
  80. <a href="?action=cookies">Manage Cookies</a>
  81. </div>
  82. <div class="title">PHProxy</div>
  83. <noscript><div class="error"><big>You have Javascript disabled. Please enable it to use the proxy</big></div></noscript>
  84. <?php
  85.  
  86. if (isset($_GET['error']))
  87. {
  88. echo '<div class="error"><b>Error:</b> ' . htmlspecialchars($_GET['error']) . '</div>';
  89. if (isset($_GET['retry']))
  90. {
  91. echo '<div class="error"><a href="'. $PHProxy->proxify_url(decode_url($_GET['retry'])) .'">Retry</a></div>';
  92. }
  93. }
  94.  
  95. if (isset($_GET['action']))
  96. {
  97. if ($_GET['action'] == 'cookies')
  98. {
  99. $cookies = $PHProxy->get_cookies('COOKIE', false);
  100.  
  101. if (!empty($cookies))
  102. {
  103. echo '<table style="width: 100%">';
  104. echo '<tr><td class="option" colspan="5"><a href="?action=cookies&delete=all">Clear All Cookies</a></td></tr>';
  105. echo '<tr><td class="head">Name</td><td class="head">Domain</td><td class="head">Path</td><td class="head">Value</td><td class="head">Action</td></tr>';
  106.  
  107. for ($i = 0; $i < count($cookies); $i++)
  108. {
  109. $j = $i&1 ? ' class="shade"' : '';
  110. echo "<tr><td$j>{$cookies[$i][0]}</td><td$j>{$cookies[$i][1]}</td><td$j>{$cookies[$i][2]}</td>"
  111. . "<td$j>" . wordwrap($cookies[$i][3], 15, ' ') ."</td><td$j><a href=". '"?action=cookies&delete='. md5(implode('', $cookies[$i])) . '">delete</a></td></tr>';
  112. }
  113.  
  114. echo '</table>';
  115. }
  116. else
  117. {
  118. echo '<div class="error">No cookies available.</div>';
  119. }
  120. }
  121. else if ($_GET['action'] == 'auth' && isset($_GET['server'], $_GET['realm'], $_GET['auth_url']))
  122. {
  123. echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
  124. echo '<input type="hidden" name="server" value="'. $_GET['server'] .'" />';
  125. echo '<input type="hidden" name="realm" value="'. $_GET['realm'] .'" />';
  126. echo '<input type="hidden" name="auth_url" value="'. $_GET['auth_url'] .'" />';
  127. echo '<table style="width: 100%">';
  128. echo '<tr><td colspan="2" class="option">Enter user name and password for <b>' . decode_url($_GET['realm']) . '</b> at <i>' . decode_url($_GET['server']) . '</i></td></tr>';
  129. echo '<tr><td width="30%" class="option">User name</td><td class="option"><input type="text" name="username" value="" /></td></tr>';
  130. echo '<tr><td width="30%" class="option">Password</td><td class="option"><input type="password" name="password" value="" /></td></tr>';
  131. echo '<tr><td colspan="2" style="text-align: center"><input type="submit" value="OK" /></td></tr>';
  132. echo '</table>';
  133. echo '</form>';
  134. }
  135. }
  136. else
  137. {
  138. ?>
  139. <form name="<?php echo $PHProxy->config['proxy_url_form_name'] ?>" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  140. <input type="hidden" name="<?php echo $PHProxy->config['url_var_name'] ?>" value="" id="url_input" />
  141. <input type="hidden" name="<?php echo $PHProxy->config['flags_var_name'] ?>" value="" />
  142. </form>
  143. <form name="<?php echo $PHProxy->config['proxy_settings_form_name'] ?>" method="get" action="" onsubmit="return submit_form();">
  144. <table style="width: 100%">
  145. <tr><td class="option" style="width: 20%">URL</td><td class="option" style="width: 80%">&nbsp;<input type="text" name="url" size="70" value="" id="url" /></td></tr>
  146. <?php echo $PHProxy->options_list(true, true) ?>
  147. <tr><td class="option" style="width: 20%">New Window</td><td class="option" style="width: 80%"><input type="checkbox" name="new_window" />Open URL in a new window </td></tr>
  148. </table>
  149. <div style="text-align: center"><input type="submit" name="browse" value="Browse" onclick="return submit_form();" /></div>
  150. <div style="text-align: center">PHProxy <?php echo $PHProxy->version ?> &copy; 2005 <a href="http://www.whitefyre.com/">whiteFyre</a>
  151. </div>
  152. </form>
  153. <?php
  154. }
  155.  
  156. echo '</div></body></html>';
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment