PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/home.php

https://bitbucket.org/daao87/personal-site
PHP | 190 lines | 68 code | 5 blank | 117 comment | 5 complexity | 3e178fa016af02115fadea2ebd9bf5af MD5 | raw file
  1. <?php
  2. session_start();
  3. if(!isset($_SESSION['username'])){
  4. header("Location: index.php");
  5. die("You are not logged in. Please go to <a href='index.php'>login</a>");
  6. }
  7. $valid_ext = array("TXT","txt","htm","HTM","html","HTML","shtm","SHTM","shtml","SHTML","pl","PL","cgi","CGI","CSS","css","conf","CONF","ASP","asp","JSP","jsp","js","JS","php","PHP","php3","PHP3","PHTML","phtml","ini","INI","cfm","CFM","inc","INC","xml","XML");
  8. function drawFolder($dir,$valid_ext){
  9. drawLinks(glob($dir."*.*"),$valid_ext);
  10. $folders = glob($dir . "*");
  11. foreach($folders as $folder){
  12. drawLinks(glob($folder."/" . "*.*"),$valid_ext);
  13. }
  14. }
  15. function drawLinks($pages,$valid_ext){
  16. if(!empty($pages)){
  17. foreach($pages as $page){
  18. $page = substr($page,2);
  19. $ext = substr(strrchr($page, '.'), 1);
  20. $pageText = "<span style='font-size:11px;'><em>".substr($page, 0, strrpos( $page, '/') )."/</em></span>&nbsp;".substr(strrchr($page, '/'), 1);
  21. if (in_array($ext,$valid_ext) && is_writable("../".$page)) {
  22. echo '<a class="pageLink" title="Edit now!" href="code-editor.php?p='.'..'.$page.'">'.$pageText.'</a><br />';
  23. }
  24. }
  25. }
  26. }
  27. ?>
  28. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  29. <html xmlns="http://www.w3.org/1999/xhtml">
  30. <head>
  31. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  32. <title>Admin Area - Overview</title>
  33. <link rel="stylesheet" type="text/css" href="css/main.css" />
  34. <link rel="stylesheet" type="text/css" href="css/home.css" />
  35. <script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
  36. <script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="../js/inc/jquery181.js"><\/script>')</script>
  37. <script type="text/javascript" language="javascript" src="js/main.js"></script>
  38. <script type="text/javascript" language="javascript" src="js/home.js"></script>
  39. </head>
  40. <body>
  41. <div id="headerWrapper"><div id="header">
  42. <h1>
  43. <a href="home.php">Admin</a>
  44. <a href="../" target='_blank' style='font-size:16px; margin-left:30px;'>Visit site</a>
  45. <a href="../mobile.php" target='_blank' style='font-size:16px; margin-left:30px;'>Visit mobile site</a>
  46. <a href="sitemap.php" target='_blank' style='font-size:16px; margin-left:30px;'>Build Sitemap</a>
  47. </h1>
  48. <a id="logoutLink" href="#" onclick='logout();'>Logout</a>
  49. </div></div>
  50. <div id="wrapper">
  51. <table width="100%" >
  52. <thead valign="top" align="left">
  53. <tr >
  54. <th style='width:50%;'>
  55. <h2>Your Pages</h2>
  56. </th>
  57. <th>
  58. <h2>Other Files</h2>
  59. </th>
  60. <th>
  61. </th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. <tr valign="top">
  66. <td style='padding:0 10px;'>
  67. <?php
  68. //get all pages
  69. $pages = glob("../pages/*.*");
  70. if(!empty($pages)){
  71. foreach($pages as $page){
  72. $page = substr($page,2);
  73. $ext = substr(strrchr($page, '.'), 1);
  74. $pageText = "<span style='font-size:11px;'><em>pages/</em></span>&nbsp;".substr(strrchr($page, '/'), 1);
  75. if (in_array($ext,$valid_ext) && is_writable("../".$page)) {
  76. echo '<a class="pageLink" title="Edit now!" href="page-editor.php?p='.substr($page,7).'">'.$pageText.'</a><br />';
  77. }
  78. }
  79. }
  80. $folders = glob("../pages/*");
  81. foreach($folders as $folder){
  82. $pages = glob($folder."/" . "*.*");
  83. if(!empty($pages)){
  84. foreach($pages as $page){
  85. $page = substr($page,2);
  86. $ext = substr(strrchr($page, '.'), 1);
  87. $pageText = "<span style='font-size:11px;'><em>".substr($page, 0, strrpos( $page, '/') )."/</em></span>&nbsp;".substr(strrchr($page, '/'), 1);
  88. if (in_array($ext,$valid_ext) && is_writable("../".$page)) {
  89. echo '<a class="pageLink" title="Edit now!" href="page-editor.php?p='.substr($page,7).'">'.$pageText.'</a><br />';
  90. }
  91. }
  92. }
  93. }
  94. ?><br />
  95. <a href="#" id="newPage">New page</a>
  96. <div id="newPageWrapper"><em>The page will be made in /pages/ directory</em><br /><br />
  97. filename: <input id="newPageName" size="25"/><br /><br />
  98. <button id="newPageSubmit">Create</button><span id="newPageMsgbox"></span>
  99. </div>
  100. </td><td style='padding:0 10px;' width="50%">
  101. <h3 style='margin-top:0px;'>Config</h3>
  102. <?php
  103. drawFolder("../config/",$valid_ext);
  104. ?>
  105. <br />
  106. <h3>Javascript</h3>
  107. <?php
  108. drawFolder("../js/",$valid_ext);
  109. ?>
  110. <br />
  111. <h3>CSS</h3>
  112. <?php
  113. drawFolder("../css/",$valid_ext);
  114. ?><br />
  115. </td><td style='padding:0 10px;' width="50%">
  116. <h3 style='margin-top:0px;'>Root</h3>
  117. <?php
  118. $directory = "../";
  119. drawLinks(glob($directory . "*.*"),$valid_ext);
  120. ?><br />
  121. <h3>Mobile</h3>
  122. <?php
  123. drawFolder("../mobile/",$valid_ext);
  124. ?><br />
  125. <h3>Path</h3>
  126. <form id="goPathForm"><input id="goPathLink" size="40" /><button type="submit" id="goPathSubmit">Open</button></form>
  127. </td></tr></tbody></table>
  128. <hr />
  129. <table width="100%">
  130. <tr><td colspan="2" width="50%"><h2>Plugins</h2></td><td colspan="2" width="50%"><h2>Themes</h2></td></tr>
  131. <tr valign="top">
  132. <td width="25%">
  133. <h3 style="margin-top:0;">Config</h3>
  134. <?php
  135. $folders = glob("../plugins/*");
  136. foreach($folders as $folder){
  137. if(file_exists($folder."/settings.php")){
  138. if (is_writable($folder."/settings.php")) {
  139. echo '<a class="pageLink" title="Edit now!" href="code-editor.php?p='.$folder."/settings.php".'">'.str_replace("../plugins/","",$folder).'</a><br />';
  140. }
  141. }
  142. }
  143. ?>
  144. </td><td>
  145. <h3 style="margin-top:0;">Files</h3>
  146. <?php
  147. $folders = glob("../plugins/*");
  148. foreach($folders as $key=>$folder){
  149. echo "<a href='#' id='plugindir".$key."' class='plugindirs'>".$folder."</a><div class='pluginfiles' id='pluginlink".$key."'>";
  150. drawFolder($folder."/" . "*",$valid_ext);
  151. echo "</div>";
  152. }
  153. ?>
  154. </td>
  155. <td>
  156. <h3 style="margin-top:0;"">Files</h3>
  157. <?php
  158. $folders = glob("../themes/*");
  159. foreach($folders as $key=>$folder){
  160. echo "<a href='#' id='themedir".$key."' class='themedirs'>".$folder."</a><div class='themefiles' id='themelink".$key."'>";
  161. drawFolder($folder."/" . "*",$valid_ext);
  162. echo "</div>";
  163. }
  164. ?>
  165. </td>
  166. </tr>
  167. </table>
  168. <hr />
  169. <h2>Compressing</h2>
  170. <em>This framework can compress and combine CSS and JS files. By compressing they have a smaller size and it makes your site faster to load. The framework caches the compressed files and wont make any changes to your original files, so you can edit them. The script should detect when a file is changed to update the cache. If you don't see your change, try pressing the 'Flush Cache' button. If you have the no-javascript version enabled, you must click "Rebuild NoJS" everytime you did a change to the tile config of the mobile version. To enable caching, open config.php in the root folder and set $enableCompressionCss and/or $enableCompressionJs to true.</em>
  171. <br /><br />
  172. <button id="flushCacheButton" >Flush cache!</button>
  173. <span id='flushMsgbox'></span>
  174. </div>
  175. <a id="footer" href="http://metro-webdesign.info" target="_blank">ŠThomas Verelst; only for donators</a>
  176. <!-- Please leave this line -->
  177. </body>
  178. </html>