PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/public/admin/index.php

http://flumpshop.googlecode.com/
PHP | 279 lines | 260 code | 8 blank | 11 comment | 38 complexity | e71e0d62e4b8ff7367484ac42ae5172b MD5 | raw file
  1. <?php
  2. $ajaxProvider = true;
  3. require_once '../../includes/preload.php';
  4. //Secure Redirect
  5. if ($config->getNode('secure','admin') and $_SERVER['HTTPS'] == "off") {
  6. header("Location: ".$initcfg->getNode('paths','secureRoot')."/admin");
  7. exit;
  8. }
  9. //Process Login
  10. if (isset($_POST['uname'])) {
  11. $fail = false;
  12. $result = $dbConn->query("SELECT * FROM `acp_login` WHERE uname='".htmlentities($_POST['uname'],ENT_QUOTES)."' LIMIT 1");
  13. if ($dbConn->rows($result) == 0) {
  14. $fail = true;
  15. syslog(LOG_NOTICE,"InvalidUname");
  16. } else {
  17. $row = $dbConn->fetch($result);
  18. if ($row['pass'] != md5(sha1($_POST['pass']))) {
  19. $fail = true;
  20. syslog(LOG_NOTICE,"InvalidPass");
  21. } else {
  22. syslog(LOG_NOTICE,"Success");
  23. $dbConn->query("UPDATE `acp_login` SET last_login='".$dbConn->time()."' WHERE id=".$row['id']." LIMIT 1");
  24. $_SESSION['acpusr'] = base64_encode($row['uname']."~".sha1($row['pass']));
  25. if (strtotime($row['pass_expires']) <= time()) {
  26. header('Location: change_password.php');
  27. } else {
  28. header("Location: ./");
  29. }
  30. }
  31. }
  32. }
  33. //Not Logged In
  34. if (!acpusr_validate()) {
  35. $login_action = './index.php';
  36. $login_message = 'Please enter your username and password to continue...';
  37. $login_fields = array(
  38. array(
  39. 'label' => 'Username: ',
  40. 'type' => 'text',
  41. 'id' => 'uname'
  42. ),
  43. array(
  44. 'label' => 'Password: ',
  45. 'type' => 'password',
  46. 'id' => 'pass'
  47. )
  48. );
  49. require '../../views/admin_login.inc';
  50. } else {
  51. //Logged In
  52. if (isset($_GET['frame'])) {
  53. if ($_GET['frame'] == "leftFrame") {
  54. //Left Frame
  55. ?><html>
  56. <head>
  57. <link href="jqueryui.css" rel="stylesheet" type="text/css" />
  58. <link href="style-nav.css" rel="stylesheet" type="text/css" />
  59. <script type="text/javascript" language="javascript" src="../js/jquery.js"></script>
  60. <script type="text/javascript" language="javascript" src="../js/jqueryui.js"></script>
  61. <script type="text/javascript" language="javascript" src="../js/jquery.validate.min.js"></script>
  62. <script type="text/javascript" language="javascript" src="../js/defaults.php"></script>
  63. </head>
  64. <body>
  65. <center><img src="images/logo.jpg" />
  66. <div class="header">flump<span class='header2'>shop</span> <?php echo FS_VERSION;?></div>
  67. Powered by Flumpnet<br /><br />
  68. <div id="navContainer">
  69. <div id="navAccordion">
  70. <?php
  71. if (
  72. acpusr_validate('can_add_categories') or
  73. acpusr_validate('can_edit_categories') or
  74. acpusr_validate('can_delete_categories') or
  75. acpusr_validate('can_add_products') or
  76. acpusr_validate('can_edit_products') or
  77. acpusr_validate('can_delete_products')
  78. ) {
  79. ?>
  80. <h3>Manage Catalogue</h3>
  81. <div>
  82. <?php if (acpusr_validate('can_add_categories') or acpusr_validate('can_edit_categories') or acpusr_validate('can_delete_categories')) { //Category Manager?>
  83. <a href='endpoints/switchboard/categories.php' onclick='loader("Loading Category Menu...");' target='main'>Manage Categories</a>
  84. <?php
  85. }
  86. if (acpusr_validate('can_add_products') or acpusr_validate('can_edit_products') or acpusr_validate('can_delete_products')) { //Product Manager?>
  87. <a href='endpoints/switchboard/products.php' onclick='loader("Loading Products Menu...");' target='main'>Manage Products</a>
  88. <?php
  89. }
  90. ?>
  91. </div>
  92. <?php
  93. }
  94. if (
  95. acpusr_validate('can_post_news') or
  96. acpusr_validate('can_edit_pages')
  97. ) {
  98. ?>
  99. <h3>Manage Site</h3>
  100. <div>
  101. <?php if (acpusr_validate('can_post_news') or acpusr_validate('can_edit_pages')) { //News Manager?>
  102. <a href='endpoints/switchboard/news.php' onclick='loader("Loading News Menu...");' target='main'>Manage News</a>
  103. <?php
  104. }
  105. if (acpusr_validate('can_edit_pages')) { //Page Manager
  106. ?>
  107. <a href='endpoints/switchboard/pages.php' onclick='loader("Loading Pages Menu...");' target='main'>Manage Pages</a>
  108. <a href='endpoints/switchboard/messages.php' onclick='loader("Loading Messages Menu...");' target='main'>Manage Messages</a>
  109. <?php
  110. }?>
  111. </div>
  112. <?php
  113. }
  114. if (
  115. acpusr_validate('can_create_orders') or
  116. acpusr_validate('can_view_orders') or
  117. acpusr_validate('can_edit_users')
  118. ) {
  119. ?>
  120. <h3>Manage Sales</h3>
  121. <div>
  122. <a href='endpoints/switchboard/orders.php' onclick='loader("Loading Orders Menu...");' target="main">Manage Orders</a>
  123. <a href='endpoints/switchboard/offers.php' onclick='loader("Loading Offers Menu...");' target="main">Manage Offers</a>
  124. </div>
  125. <?php
  126. }
  127. ?>
  128. <h3>Clients</h3>
  129. <div>
  130. <a href="endpoints/clients/listCustomers.php" onclick='loader("Loading Content...");' target="main">Customer Manager</a>
  131. <a href="endpoints/clients/addCustomers.php" onclick='loader("Loading Content...");' target="main">Import Customer Data</a>
  132. </div>
  133. <h3>Deliveries</h3>
  134. <div>
  135. <a href="endpoints/delivery/countries.php" onClick="loader('Loading Content...');" target="main">Supported Countries</a>
  136. <a href="endpoints/delivery/deliveryRates.php" onClick="loader('Loading Content...');" target="main">Delivery Rates</a>
  137. </div>
  138. <h3>Reports</h3>
  139. <div>
  140. <a href='endpoints/reports/customerReport.php' onclick='loader("Generating Report...");' target="main">Customer Report<sup>labs</sup></a>
  141. <a href='endpoints/reports/duplicates.php' onclick='loader("Generating Report...");' target="main">Content Suggestions<sup>labs</sup></a>
  142. </div>
  143. <h3>Advanced</h3>
  144. <div>
  145. <a href="endpoints/advanced/updateKeywords.php" onclick='loader("Generating Keywords...");' target="main">Auto-Generate Keywords</a>
  146. <a href="endpoints/advanced/varMan.php" onclick='loader("Loading Content...");' target="main">Configuration Manager</a>
  147. <a href="endpoints/advanced/clearCache.php" onclick='loader("Clearing Cache...");' target="main">Clear Cache</a>
  148. <a href="endpoints/process/cron.php" onclick='loader("Executing Cron Script...");' target="main">Cron Script</a>
  149. <a href="endpoints/advanced/execute.php" onclick='loader("Loading Content...");' target="main">Execute PHP</a>
  150. <a href="endpoints/advanced/query.php" onclick='loader("Loading Content...");' target="main">Execute SQL</a>
  151. <a href="endpoints/advanced/bugs.php" onclick='loader("Loading Content...");' target="main">Feedback</a>
  152. <a href="endpoints/advanced/upload.php" onclick='loader("Loading Content...");' target="main">File Upload</a>
  153. <a href="logs" onclick='loader("Loading Content...");' target="main">Log Viewer</a>
  154. <a href="endpoints/advanced/mailQueue.php" onclick="loader('Loading Content...');" target="main">Mail Queue</a>
  155. <a href="endpoints/advanced/popularBlacklist.php" onclick="loader('Loading Content...');" target="main">Popular Items Blacklist</a>
  156. <a href="endpoints/advanced/phpinfo.php" onclick='loader("Loading Content...");' target="main">PHP Info</a>
  157. <a href="endpoints/advanced/recreateImages.php" onclick='loader("Loading Content...");' target="main">Rebuild Images</a>
  158. <a href="endpoints/advanced/userManager.php" onclick='loader("Loading Content...");' target="main">User Manager</a>
  159. </div>
  160. <h3>Plugins</h3>
  161. <div>
  162. <a href="endpoints/plugins/plugins.php" onclick='loader("Loading Content...");' target="main">Plugin Manager</a><?php
  163. //Each plugin that has /endpoints/index.php will have an option displayed here
  164. $dir = opendir($config->getNode('paths','offlineDir')."/plugins");
  165. while ($module = readdir($dir)) {
  166. if (file_exists($config->getNode('paths','offlineDir')."/plugins/".$module."/endpoints/index.php")) {
  167. echo '<a href="endpoints/plugins/pluginProvider.php?mod='.$module.'&page=index" onclick=\'loader("Loading Content...");\' target="main">'.$module.'</a>';
  168. }
  169. }
  170. ?></div>
  171. <h3>Credits</h3>
  172. <div>Developed by Flumpnet. The system makes use of the TinyMCE Editor, jQuery and the jQueryUI Framework, and FPDF (+Sphider?)</div>
  173. </div>
  174. </div>
  175. </center>
  176. <script type="text/javascript">
  177. $(document).ready(function() {
  178. $('#navAccordion').accordion({collapsible: true, active: false, autoHeight: false, icons: {'header': 'ui-icon-circle-arrow-e', 'headerSelected': 'ui-icon-circle-arrow-s'}});
  179. });
  180. function loader(str) {
  181. $(parent.main.document.getElementById('dialog')).html(loadMsg(str));
  182. if (typeof(parent.main.loadDialog) == "function") {
  183. parent.main.loadDialog();
  184. }
  185. return false;
  186. }
  187. </script>
  188. </body>
  189. </html><?php
  190. } elseif ($_GET['frame'] == "header") {
  191. //Header Frame
  192. ?><html>
  193. <head><link href="style-header.css" rel="stylesheet" type="text/css" /></head>
  194. <body>
  195. <h1 class="title">ADMINISTRATOR CONTROL PANEL</h1>
  196. <p class="version">Latest Version Available: <?php echo file_get_contents("http://flumpshop.googlecode.com/svn/updater/version.txt");?> <a href='upgrade' target='_top'>Upgrade Wizard</a></p>
  197. <div class="right">
  198. <h1>flump<span class="header2">shop</span> <?=FS_VERSION?></h1>
  199. <p><a href='../account/logout.php' target="_top">Logout</a> | <a href='../' target="_top">View live storefront</a></p>
  200. </div>
  201. </body>
  202. </html><?php
  203. } elseif ($_GET['frame'] == "main") {
  204. //Main Frame
  205. ?><html>
  206. <head><link href="style-main.css" rel="stylesheet" type="text/css" /><link href="jqueryui.css" rel="stylesheet" type="text/css" /><script src="../js/jquery.js"></script><script src="../js/jqueryui.js"></script><script>function loadDialog() {$('#dialog').dialog();}</script></head>
  207. <body>
  208. <h1>Flumpshop v<?=FS_VERSION?></h1>
  209. <h2>Admin CP</h2><?php
  210. //Check for possible security issues
  211. if (file_exists("setup")) {
  212. echo "<div class='ui-state-error'><span class='ui-icon ui-icon-alert'></span><strong>Security Issue</strong> - After initial installation, it is recommended that your rename or delete the /admin/setup folder in order to increase security.</div>";
  213. }
  214. //Check for Updates
  215. if (!$latestVer = file_get_contents("http://flumpshop.googlecode.com/svn/updater/version.txt")) {
  216. echo "<div class='ui-state-highlight'><span class='ui-icon ui-icon-extlink'></span><strong>Connection Failure</strong> - An error occured checking for updates.</div>";
  217. } elseif (FS_VERSION < $latestVer) {
  218. echo "<div class='ui-state-highlight'><span class='ui-icon ui-icon-notice'></span><strong>Update Available</strong> - An update is available for installation. To install, click the Upgrade Wizard button above.</div>";
  219. }
  220. //Check for unread feedback
  221. $result = $dbConn->query("SELECT * FROM `bugs` WHERE resolved = 0");
  222. if ($dbConn->rows($result) != 0) {
  223. echo "<div class='ui-state-highlight'><span class='ui-icon ui-icon-notice'></span><strong>New Feedback</strong> - Unread Feedback is available in Advanced->Feedback</div>";
  224. }
  225. ?><div id='dialog'></div>
  226. <h2>Getting Started Checklist</h2>
  227. <p>Just starting out on setting up your own website? Here's a little checklist to get you started.</p>
  228. <ul>
  229. <li><strong>Create your own login</strong> - The inituser account won't last forever, so head over to Advanced->User Manager to set up a permanent account for yourself and anyone else who you want to be able to administer your account.</li>
  230. <li><strong>Add some categories</strong> - Create sections for items to be in. You can do this later, but it helps to keep things organised right from the start.</li>
  231. <li><strong>Add some products</strong> - Start adding your products to the site. With the new Manage Products feature, doing this is an absolute breeze.</li>
  232. <li><strong>Post some news</strong> - At the moment, there's only placeholder content for some sections of your site. Make sure that if they're turned on, that they are customised.
  233. <ul>
  234. <li>Home Page News (News->New News Post)</li>
  235. <li>Home Page Technical Tips (News->New Technical Tips Post)</li>
  236. <li>Home Page Content (Pages->Home Page)</li>
  237. <li>About Page Content (Pages->About Page)</li>
  238. <li>Contact Page Content (Pages->Contact Page)</li>
  239. </ul>
  240. </li>
  241. </ul>
  242. <p>Those are all the basics to get a site up and running. If you're selling online, make sure to take a look over in the deliveries section to to set delivery costs.</p>
  243. <p>Remember, Flumpshop is a fully featured management system. Import existing customers and orders, and the site can greatly improve your business efficiency with a centralised location for all your information, but you must first take the time out to add all this information.</p>
  244. </body>
  245. </html><?php
  246. }
  247. } else {
  248. //Frames not sent yet
  249. if (!isset($_SESSION['acpLoaded'])) {
  250. //Load resources, particularly for TinyMCE
  251. include 'loader.php';
  252. } else {
  253. //Ready to send frames
  254. /**
  255. * If the jump parameter is specified, load this instead of the main frame
  256. */
  257. $main = '?frame=main';
  258. if (isset($_GET['jump'])) $main = 'endpoints/'.$_GET['jump'];
  259. ?><html><head><title>Flumpshop | Admin CP</title></head>
  260. <frameset cols="252px,*" framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
  261. <frame name="leftFrame" id="leftFrame" src="?frame=leftFrame" scrolling="yes" frameborder="0" marginwidth="0" marginheight="0" border="no" />
  262. <frameset rows="60px,*" framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
  263. <frame src="?frame=header" name="header" id="header" scrolling="no" noresize="noresize" frameborder="0" marginwidth="10" marginheight="0" border="no" />
  264. <frame src="<?php echo $main;?>" name="main" id="main" scrolling="yes" frameborder="0" marginwidth="10" marginheight="10" border="no" />
  265. </frameset>
  266. </frameset>
  267. </html><?php
  268. }
  269. }
  270. }
  271. ?>