PageRenderTime 1346ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/2Q Modules/Webserver/website/cfg/index.php

http://github.com/aarondl/Project-2Q
PHP | 295 lines | 255 code | 32 blank | 8 comment | 54 complexity | 4abd2db359325476b51303859f11f31a MD5 | raw file
  1. <?
  2. //AaronGET
  3. $query = getenv("QUERY_STRING");
  4. $m = strcasecmp( getenv("REQUEST_METHOD"), "GET" );
  5. $t = 0;
  6. if ( $m != 0 ) {
  7. $m = strcasecmp( getenv("REQUEST_METHOD"), "POST" );
  8. if ( $m == 0 ) { $t = 1; }
  9. }
  10. if ( $query != NULL ) {
  11. $tok1 = strtok($query, "=&");
  12. $tok2 = strtok( "=&" );
  13. while ( $tok1 != NULL ) {
  14. if ( $t == 0 ) { $_GET[$tok1] = $tok2; }
  15. elseif ( $t == 1 ) { $_POST[$tok1] = $tok2; }
  16. $tok1 = strtok( "=&" );
  17. $tok2 = strtok( "=&" );
  18. }
  19. }
  20. //AaronGET
  21. $m_amount = intval( getenv( "QQ_ENV_MNUM" ) );
  22. $m_names = ParseKey( getenv( "QQ_ENV_MNAMES" ), ";" );
  23. $m_loaded = ParseKey( getenv( "QQ_ENV_MLOADED" ), ";" );
  24. function QuickModuleInfo(){
  25. $m_amount = intval( getenv( "QQ_ENV_MNUM" ) );
  26. $m_names = ParseKey( getenv( "QQ_ENV_MPRETTYNAMES" ), ";" );
  27. $m_loaded = ParseKey( getenv( "QQ_ENV_MLOADED" ), ";" );
  28. for ( $i = 0; $i < $m_amount; $i++ ) {
  29. if ($m_names[$i] == true)
  30. echo "{$m_names[$i]}<br />";
  31. else
  32. echo "<div class=\"ModuleOffline\"> {$m_names[$i]} </div>";
  33. //printf("<tr><td>%s</td><td>%s</td></tr>", $m_names[$i], $m_loaded[$i] == "True" ? "Yes" : "No");
  34. }
  35. }
  36. function QuickChannelInfo(){
  37. $s_names = ParseKey( getenv( "QQ_ENV_SNAMES" ), ";" );
  38. $s_amount = getenv('QQ_ENV_SNUM');
  39. for ( $i = 0; $i < $s_amount; $i++ ){
  40. echo "<div class=\"ChannelServer\"><a href=\"?s=$i\">" . $s_names[$i] . "</a></div>";
  41. $a = getenv( "QQ_ENV_S". $i . "_CHANNELS");
  42. if ($a == null) break;
  43. $q = ParseKey( $a , ";");
  44. for ($g = 0; $g < sizeof($q); $g++){
  45. $r = $q[$g];
  46. echo "<a href=\"?s=$i&c=$g\">$r</a><br />";
  47. }
  48. echo "\n";
  49. }
  50. }
  51. function ChannelName( $c, $s ){
  52. $a = getenv( "QQ_ENV_S". $s . "_CHANNELS");
  53. $b = ParseKey( $a , ";");
  54. return $b[$c];
  55. }
  56. function ServerName( $s ) {
  57. $a = getenv( "QQ_ENV_SNAMES" );
  58. $b = ParseKey( $a , ";");
  59. return $b[$s];
  60. }
  61. function ListChannels( $server ){
  62. $q = "qq_env_s" . $server . "_channels";
  63. if ( getenv($q) == "" )
  64. return "Non-Existant Server.";
  65. else {
  66. $chans = "";
  67. $c = ParseKey( getenv($q), ";" );
  68. for ( $i = 0; $i < sizeof($c); $i++ ){
  69. $chans = $chans . "<a href=\"?s=" . $server . "&c=" . $i . "\">" . $c[$i] . "</a>";
  70. }
  71. return $chans;
  72. }
  73. }
  74. function ListUsers( $server, $channel ){
  75. $q = "qq_env_s" . $server . "_c" . $channel . "_names";
  76. if ( getenv($q) == "" )
  77. return "Incorrect Input!";
  78. else {
  79. $users = "";
  80. $u = ParseKey( getenv($q), ";" );
  81. if ( natsort($u) ) {
  82. for ( $i = 0; $i < sizeof($u); $i++ ){
  83. $users = $users . $u[$i] ."<br/>";
  84. }
  85. return $users;
  86. } else
  87. return "natsort";
  88. }
  89. }
  90. function ParseSemiColons( $string ) {
  91. $tmp = array();
  92. $tok = strtok($string,';');
  93. $i = 0;
  94. while ( $tok !== false ) {
  95. $tmp[$i++] = $tok;
  96. $tok = strtok(';');
  97. }
  98. return $tmp;
  99. }
  100. function natSortKey(&$arrIn )
  101. {
  102. $key_array = array();
  103. $arrOut = array();
  104. foreach ( $arrIn as $key=>$value ) {
  105. $key_array[]=$key;
  106. }
  107. natsort( $key_array);
  108. foreach ( $key_array as $key=>$value ) {
  109. $arrOut[$value]=$arrIn[$value];
  110. }
  111. $arrIn=$arrOut;
  112. }
  113. function access_strcmp( $a, $b ) {
  114. $oa = ord( $a ); $ob = ord( $b );
  115. if ( $oa == 64 && $ob != 64 ) { return -1; }
  116. if ( $oa != 64 && $ob == 64 ) { return 1; }
  117. if ( $oa == 43 && $ob != 43 ) { return -1; }
  118. if ( $oa != 43 && $ob == 43 ) { return 1; }
  119. return strcmp( $a, $b);
  120. }
  121. //PHP amazes me at it's retardism
  122. function awkwardfunction( $a ){
  123. natcasesort($a);
  124. $b = array();
  125. $i = 0;
  126. foreach ( $a as $c ){
  127. $b[$i] = $c;
  128. $i++;
  129. }
  130. unset( $a );
  131. unset( $i );
  132. //TODO: sort by member access level or something :x
  133. usort( $b , "access_strcmp" );
  134. return $b;
  135. }
  136. function ParseKey( $string, $key) {
  137. $tmp = array();
  138. $tok = strtok($string,$key);
  139. $i = 0;
  140. while ( $tok !== false ) {
  141. $tmp[$i++] = $tok;
  142. $tok = strtok(';');
  143. }
  144. return awkwardfunction($tmp);
  145. }
  146. function getexists( $key ) { return ( array_key_exists( $key, $_GET ) ) ? $_GET[$key] : NULL; }
  147. $s = getexists( "s" );
  148. $c = getexists( "c" );
  149. if ( ($s != "") && ($c != "") ){
  150. $page = 1; //Shows Users on Channel
  151. $users = ListUsers( $s, $c );
  152. $channel_name = ChannelName( $c, $s );
  153. $server_name = ServerName( $s );
  154. }
  155. else if ( $s != "" ){
  156. $page = 0; //Show Channels on Server
  157. $channels = ListChannels( $s );
  158. $server_name = ServerName( $s );
  159. }
  160. else {
  161. $page = 2; //Default
  162. }
  163. ?>
  164. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  165. <html xmlns="http://www.w3.org/1999/xhtml">
  166. <head>
  167. <!--Designed by Dylan Johnston-->
  168. <!--Monday, November 12, 2007 -->
  169. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  170. <meta name="description" content="Project2Q, An opensource C# IRC Bot." />
  171. <title>Project2Q</title>
  172. <link rel="stylesheet" type="text/css" href="style.css" />
  173. </head>
  174. <body>
  175. <!--Outline Start-->
  176. <div class="OutLine">
  177. <!--Header Start-->
  178. <div class="Header">
  179. <div class="HeaderText">#Project2Q<br />irc.nuclearfallout.net</div>
  180. </div>
  181. <!--Header End-->
  182. <!--Project Information Start-->
  183. <div class="ProjectInformationWrapper">
  184. <!--Modules Start-->
  185. <div class="Modules">
  186. <!--Module Header start-->
  187. <div class="ModuleHeader"> Modules Installed </div>
  188. <!--Module Header End-->
  189. <? QuickModuleInfo(); ?>
  190. </div>
  191. <!--Modules End-->
  192. <!--Channels Start-->
  193. <div class="Channels">
  194. <!--Channel Header Start-->
  195. <div class="ChannelHeader"> Current Channels </div>
  196. <!--Channel Header End-->
  197. <? QuickChannelInfo(); ?>
  198. <!--Channels End-->
  199. </div>
  200. <!--Gap Start-->
  201. <div class="Gap">
  202. <!--Gap Header Start-->
  203. <div class="GapHeader">&nbsp;</div>
  204. <!--Gap Header End-->
  205. </div>
  206. <!--Gap End-->
  207. </div>
  208. <!--Project Information End-->
  209. <?
  210. switch ( $page ){
  211. case 0:
  212. //SHOW CHANNELS ON A SERVER
  213. ?>
  214. <!--Information Start-->
  215. <div class="InformationWrapper">
  216. <!--Information Header Start-->
  217. <div class="InformationHeader"> Channels on <? echo $server_name; ?> </div>
  218. <!--Information Header End-->
  219. <? echo $channels; ?>
  220. </div>
  221. <!--Information End-->
  222. <?
  223. break;
  224. case 1:
  225. //SHOW USERS ON A CHANNEL
  226. ?>
  227. <!--Information Start-->
  228. <div class="InformationWrapper">
  229. <!--Information Header Start-->
  230. <div class="InformationHeader"> Users in <? echo $channel_name; ?> on <? echo $server_name; ?></div>
  231. <!--Information Header End-->
  232. <? echo $users; ?>
  233. </div>
  234. <!--Information End-->
  235. <?
  236. break;
  237. case 2:
  238. default:
  239. //SHOW DEFAULT
  240. ?>
  241. <!--Information Start-->
  242. <div class="InformationWrapper">
  243. <!--Information Header Start-->
  244. <div class="InformationHeader"> Information </div>
  245. <!--Information Header End-->
  246. Project2Q is an modular irc bot written in C#.
  247. </div>
  248. <!--Information End-->
  249. <?
  250. break;
  251. }
  252. ?>
  253. <!--Bottom Start-->
  254. <div class="Bottom">
  255. <!--Bottom Text Start-->
  256. <div class="BottomText"> <a href="mailto: aaronl_d@hotmail.com" title="Aaron Lefkowitz">Aaron Lefkowitz</a> & <a href="mailto: dylanjohnston@gmail.com" title="Dylan Johnston"> Dylan Johnston </a> </div>
  257. <!--Bottom Text End-->
  258. </div>
  259. <!--Bottom End-->
  260. </div>
  261. <!--OutLine End-->
  262. </body>
  263. </html>