PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tab_admincp.php

http://thegamesdb.googlecode.com/
PHP | 320 lines | 284 code | 25 blank | 11 comment | 21 complexity | f810224208df8e37444b58e0d83d95bd MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0, AGPL-3.0, BSD-3-Clause
  1. <?php if ($adminuserlevel == 'ADMINISTRATOR') { ?>
  2. <?php
  3. ##Image Resizing and caching script
  4. include('simpleimage.php');
  5. function imageDualResize($filename, $cleanFilename, $wtarget, $htarget)
  6. {
  7. if(!file_exists($cleanFilename))
  8. {
  9. $dims = getimagesize($filename);
  10. $width = $dims[0];
  11. $height = $dims[1];
  12. while($width > $wtarget || $height > $htarget)
  13. {
  14. if($width > $wtarget)
  15. {
  16. $percentage = ($wtarget / $width);
  17. }
  18. if($height > $htarget)
  19. {
  20. $percentage = ($htarget / $height);
  21. }
  22. /*if($width > $height)
  23. {
  24. $percentage = ($target / $width);
  25. }
  26. else
  27. {
  28. $percentage = ($target / $height);
  29. }*/
  30. //gets the new value and applies the percentage, then rounds the value
  31. $width = round($width * $percentage);
  32. $height = round($height * $percentage);
  33. }
  34. $image = new SimpleImage();
  35. $image->load($filename);
  36. $image->resize($width, $height);
  37. $image->save($cleanFilename);
  38. $image = null;
  39. }
  40. //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
  41. return "src=\"$baseurl/$cleanFilename\"";
  42. }
  43. ?>
  44. <?php if (!isset($cptab)) { $cptab = "userinfo"; } ?>
  45. <div id="gameWrapper">
  46. <div id="gameHead">
  47. <?php if($errormessage): ?>
  48. <div class="error"><?= $errormessage ?></div>
  49. <?php endif; ?>
  50. <?php if($message): ?>
  51. <div class="message"><?= $message ?></div>
  52. <?php endif; ?>
  53. <div>
  54. <h1>Admin Control Panel</h1>
  55. <p>&nbsp;</p>
  56. </div>
  57. <div id="controlPanelWrapper">
  58. <div id="controlPanelNav">
  59. <ul>
  60. <li<?php if($cptab == "userinfo"){ ?> class="active" <?php } ?>><a href="<?= $baseurl ?>/admincp/?cptab=userinfo">My User Info</a></li>
  61. <li<?php if($cptab == "addplatform"){ ?> class="active" <?php } ?>><a href="<?= $baseurl ?>/admincp/?cptab=addplatform">Add New Platform</a></li>
  62. <li<?php if($cptab == "publishers"){ ?> class="active" <?php } ?>><a href="<?= $baseurl ?>/admincp/?cptab=pubdev">Manage Publishers &amp; Developers</a></li>
  63. <li<?php if($cptab == "sendpm"){ ?> class="active" <?php } ?>><a href="<?= $baseurl ?>/admincp/?cptab=sendpm">Send PM</a></li>
  64. <li<?php if($cptab == "platformalias"){ ?> class="active" <?php } ?>><a href="<?= $baseurl ?>/admincp/?cptab=platformalias">Generate Platform Alias's</a></li>
  65. </ul>
  66. </div>
  67. <div id="controlPanelContent">
  68. <?php
  69. switch($cptab)
  70. {
  71. case "userinfo":
  72. ?>
  73. <h2>User Information | <?=$user->username?></h2>
  74. <p>&nbsp;</p>
  75. <div style="float:left;">
  76. <form style="padding: 14px; border: 1px solid #999; background-color: #444444;" method="post" action="<?= $baseurl; ?>/admincp/" enctype="multipart/form-data">
  77. <h2>User Image...</h2>
  78. <?php
  79. $filename = glob("banners/users/" . $user->id . "-*.jpg");
  80. if(file_exists($filename[0]))
  81. {
  82. ?>
  83. <p style="text-align: center;"><img src="<?= $baseurl; ?>/<?= $filename[0]; ?>" alt="Current User Image" title="Current User Image" /></p>
  84. <?php
  85. $filename = null;
  86. }
  87. else
  88. {
  89. ?>
  90. <p style="text-align: center;"><img src="<?= $baseurl; ?>/images/common/icons/user-black_64.png" alt="Current User Image" title="Current User Image" /></p>
  91. <?php
  92. }
  93. ?>
  94. <p style="text-align: center;">
  95. <input type="file" name="userimage" /><br />
  96. <input type="hidden" name="function" value="Update User Image" />
  97. <input type="submit" name="submit" value="Upload Image" /></p>
  98. </form>
  99. </div>
  100. <form action="<?=$fullurl?>" method="POST" style="float:left; border-left: 1px solid #333; padding-left: 16px; margin-left: 16px;">
  101. <table cellspacing="2" cellpadding="2" border="0" align="center">
  102. <tr>
  103. <td><b>Password</b></td>
  104. <td><input type="password" name="userpass1"></td>
  105. </tr>
  106. <tr>
  107. <td><b>Re-Enter Password</b></td>
  108. <td><input type="password" name="userpass2"></td>
  109. </tr>
  110. <tr>
  111. <td><b>Email Address</b></td>
  112. <td><input type="text" name="email" value="<?=$user->emailaddress?>"></td>
  113. </tr>
  114. <tr>
  115. <td><b>Preferred Language</b></td>
  116. <td>
  117. <select name="languageid" size="1">
  118. <?php
  119. ## Display language selector
  120. foreach ($languages AS $langid => $langname) {
  121. ## If we have the currently selected language
  122. if ($user->languageid == $langid) {
  123. $selected = 'selected';
  124. }
  125. ## Otherwise
  126. else {
  127. $selected = '';
  128. }
  129. print "<option value=\"$langid\" $selected>$langname</option>\n";
  130. }
  131. ?>
  132. </select>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td><b>Account Identifier</b></td>
  137. <td><input type="text" name="form_uniqueid" value="<?=$user->uniqueid?>" readonly></td>
  138. </tr>
  139. <tr>
  140. <td></td>
  141. <td><input type="submit" name="function" value="Update User Information"></td>
  142. </tr>
  143. </table>
  144. </form>
  145. <?php
  146. break;
  147. case "addplatform":
  148. ?>
  149. <h2>Add a Platform...</h2>
  150. <p>&nbsp;</p>
  151. <form method="post" action="<?= $baseurl; ?>/admincp/" enctype="multipart/form-data">
  152. <p style="text-align: center;"><img src="<?= $baseurl; ?>/images/common/consoles/png24/console_default.png" style="vertical-align: middle;" />&nbsp;To create a new platform, enter it's name below.</p>
  153. <p style="text-align: center; font-weight: bold;">Platform Name:&nbsp;<input type="text" name="PlatformTitle" size="60" /><br />
  154. <input type="hidden" name="function" value="Add Platform" />
  155. <input type="submit" name="submit" value="Add New Platform" style="padding: 6px;" /></p>
  156. </form>
  157. <?php
  158. break;
  159. case "pubdev":
  160. ?>
  161. <h2>Manage Publishers and Developers</h2>
  162. <p>&nbsp;</p>
  163. <p style="text-align: center;"><a style="color: orange;" href="<?= $baseurl ?>/addpub/">Add new Publisher/Developer</a></p>
  164. <table align="center" border="1" cellspacing="0" cellpadding="7" bgcolor="#888888">
  165. <tr>
  166. <th style="background-color: #333; color: #FFF;">Keywords</th>
  167. <th style="background-color: #333; color: #FFF;">Logo</th>
  168. <th style="background-color: #333; color: #FFF;">Action</th>
  169. </tr>
  170. <?php
  171. $pubdevQuery = mysql_query(" SELECT * FROM pubdev ORDER BY keywords ASC");
  172. while($pubdevResult = mysql_fetch_object($pubdevQuery))
  173. {
  174. ?>
  175. <tr>
  176. <td><?= $pubdevResult->keywords ?></td>
  177. <?php
  178. if(!file_exists("banners/_admincpcache/publisher-logos/$pubdevResult->logo"))
  179. {
  180. WideImage::load("banners/publisher-logos/$pubdevResult->logo")->resize(400, 60)->saveToFile("banners/_admincpcache/publisher-logos/$pubdevResult->logo");
  181. }
  182. ?>
  183. <td><img src="<?= $baseurl ?>/banners/_admincpcache/publisher-logos/<?= $pubdevResult->logo ?>" style="vertical-align: middle;" /></td>
  184. <td><a style="color: orange;" href="<?= $baseurl ?>/updatepub/?publisherid=<?= $pubdevResult->id ?>">Update Keywords &amp; Logo</a></td>
  185. </tr>
  186. <?php
  187. }
  188. ?>
  189. </table>
  190. <?php
  191. break;
  192. case "sendpm":
  193. ?>
  194. <h2>Send PM to User...</h2>
  195. <form action="<?= $baseurl; ?>/admincp/?cptab=sendpm" method="post">
  196. <span style="float: right;"><input type="submit" name="function" value="Send PM" /></span>
  197. <p><b>Send To:</b>&nbsp;<input type="text" name="pmto" id="pm-to" size="36" /> <a href="#pm-userlist" rel="facebox">User List</a></p>
  198. <p><b>Subject:</b>&nbsp;&nbsp;<input type="text" name="pmsubject" size="36" /></p>
  199. <p><b>Message:</b><br />
  200. <textarea name="pmmessage" style="width: 100%; height: 300px;"></textarea></p>
  201. </form>
  202. <!-- User List-->
  203. <div id="pm-userlist" style="display: none;">
  204. <div style="height: 400px; overflow: auto;">
  205. <p>
  206. <?php
  207. $userlistQuery = mysql_query("SELECT id, username FROM users ORDER BY username ASC");
  208. while($userlist = mysql_fetch_object($userlistQuery))
  209. {
  210. ?>
  211. <a href="javascript: void();" onclick="$('#pm-to').val('<?= $userlist->username ?>'); jQuery(document).trigger('close.facebox');"><?= $userlist->username; ?></a><br />
  212. <?php
  213. }
  214. ?>
  215. </p>
  216. </div>
  217. </div>
  218. <?php
  219. break;
  220. default:
  221. ?>
  222. <p>&nbsp;</p>
  223. <h2 class="arcade">Please select a section to administrate...</h2>
  224. <p>&nbsp;</p>
  225. <?php
  226. break;
  227. case "platformalias":
  228. ?>
  229. <h2>Generate Platform Alias'...</h2>
  230. <form action="<?= $baseurl; ?>/admincp/?cptab=platformalias" method="post" style="text-align: center; padding: 16px; border: 1px solid #666; background-color: #333; color: #fff; margin: 16px;">
  231. <p style="font-size: 18px;">Press the button below to auto-generate alias's for platforms missing an alias.</p>
  232. <input type="submit" name="function" value="Generate Platform Alias's" style="padding: 16px;" />
  233. </form>
  234. <table align="center" border="1" cellspacing="0" cellpadding="7" bgcolor="#888888">
  235. <tr>
  236. <th style="background-color: #333; color: #FFF;" width="14%">ID</th>
  237. <th style="background-color: #333; color: #FFF;" width="43%">Name</th>
  238. <th style="background-color: #333; color: #FFF;" width="43%">Alias</th>
  239. </tr>
  240. <?php
  241. $platformsResult = mysql_query(" SELECT p.id, p.name, p.alias FROM platforms AS p ORDER BY p.id ");
  242. while($platforms = mysql_fetch_object($platformsResult))
  243. {
  244. if ($class == 'odd') { $class = 'even'; } else { $class = 'odd'; }
  245. ?>
  246. <tr class="<?= $class; ?>">
  247. <td align="center"><?= $platforms->id; ?></td>
  248. <td><?= $platforms->name; ?></td>
  249. <td><?php if($platforms->alias == "") { echo "N/A"; } else { echo $platforms->alias; } ?></td>
  250. </tr>
  251. <?php
  252. }
  253. ?>
  254. </table>
  255. <?php
  256. break;
  257. default:
  258. ?>
  259. <p>&nbsp;</p>
  260. <h2 class="arcade">Please select a section to administrate...</h2>
  261. <p>&nbsp;</p>
  262. <?php
  263. break;
  264. }
  265. ?>
  266. </div>
  267. <div style="clear: both;"></div>
  268. </div>
  269. <?php
  270. }
  271. else {
  272. ?>
  273. <div style="text-align: center;">
  274. <h2 class="arcade">Sorry...</h2>
  275. <h2>Only administrators are allowed access to this section.</h2>
  276. </div>
  277. <?php
  278. }
  279. ?>
  280. </div>
  281. </div>