Admin panel for item mall

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Admin panel for item mall

Postby hoegarden31 on Mon Feb 27, 2012 3:03 pm

Warning : This code is ONLY for those who have installed the script Itemmall v2

Create a file called add_category into your modules, then put this code in it :
  1. <?php
  2. /*
  3. DynastyCMS
  4. Copyrigt (C) 2007 dynastycms
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19.  
  20. Custom made By Jo Boermans/Zblork31/Hoegarden31
  21. */
  22.  
  23. if(!session_is_registered(Admin)) {
  24. die('Access Denied');
  25. }
  26.  
  27. if(isset($_POST['submit'])) {
  28.     $cat_hidden     = 0;
  29.     $cat_name       = isset($_POST['cat_name']) ? mysql_real_escape_string($_POST['cat_name']) : null;
  30.     $cat_desc       = isset($_POST['cat_desc']) ? mysql_real_escape_string($_POST['cat_desc']) : null;
  31.     $cat_minlevel   = isset($_POST['cat_minlevel']) ? intval($_POST['cat_minlevel']) : 100;
  32.     $cat_parent     = isset($_POST['cat_parent']) ? intval($_POST['cat_parent']) : -1;
  33.     $error = array();
  34.    
  35.     if(!$cat_name){
  36.         $error[] = 'Name required!';
  37.     }
  38.     if(!$cat_minlevel){
  39.         $cat_minlevel = 100;
  40.     }
  41.     if(!$cat_parent || $cat_parent == 0){
  42.         $cat_parent = -1;
  43.     }
  44.     if(count($error) > 0){
  45.         echo('<table width="100%" align="center">
  46.                 <tr>
  47.                 <td>Errors:</td>
  48.                 </tr>');
  49.         foreach($error as $errors){
  50.             echo('<tr>
  51.                     <td>'.$errors.'</td>
  52.                 </tr>');
  53.         }
  54.             echo('</table>');
  55.             echo('<a href="?op=add_category"><==Go back</a>');
  56.     }
  57.     elseif(count($error) == 0){
  58.         $sql = "INSERT INTO mall_category (ctitle,cdesc,cparent,cminlevel,chidden) VALUES ('%s','%s',%d,%d,%d);";
  59.         $sql = sprintf($sql,$cat_name,$cat_desc,$cat_parent,$cat_minlevel,intval($cat_hidden));
  60.         $res = @mysql_query($sql);
  61.         echo 'Category added.';
  62.     }
  63. } else {
  64.     $all_cat = mysql_query("Select * FROM mall_category") or die(mysql_error());
  65. ?>
  66. <form id="form1" name="form1" method="post" action="?op=add_category">
  67. <table>
  68.     <tr>
  69.     <td>Categorie Name: </td>
  70.     <td><input type="text" name="cat_name"></td>
  71.   </tr>
  72.   <tr>
  73.     <td>Categorie Description: </td>
  74.     <td><input type="text" name="cat_desc"></td>
  75.   </tr>
  76.   <tr>
  77.     <td>Parent Categorie (if none is selected then it will be stored as a main category): </td>
  78.     <td>
  79.     <?php
  80.         $html = '<select name="cat_parent">';
  81.         $html .= '<option value='0'>None</option>';
  82.         while ( $r = mysql_fetch_array($all_cat) ) {
  83.             $html .= '<option value='.$r['cid'].'>'.$r['ctitle'].'</option>';
  84.         }
  85.         $html .= '</select>';
  86.         echo($html);
  87.     ?>
  88.     </td>
  89.   </tr>
  90.   <tr>
  91.     <td>Categorie Minimum level (Minimul GM level required to access the category): </td>
  92.     <td><input type="text" name="cat_minlevel"></td>
  93.   </tr>
  94. </table>
  95. <p align="center">
  96.   <input name="submit" type="submit" id="submit" />
  97.   <br />
  98.   <br />
  99. </p>
  100. </form>
  101. <?php
  102. }
  103. ?>

Has you can see, i put by default hidden on 0. As there is no module to edit category's, you will have to put them manually in an hidden position if you want. Can be changed after a few comments :P

Then go into your admin menu, and add this code :
  1. <div id="nav_content">
  2.     <div id="nav_top">Item Mall Management</div>
  3.     <div id="nav_bottom">
  4.         <a href="?op=add_category">Add categories</a><br />
  5.         <a href="?op=add_items">Add items</a><br />
  6.         <a href="?op=add_forsale">Add for sale items</a>
  7.     </div>
  8. </div>

As you can see, i will make a module "add_items" and "add_forsale". When they are done, i will edit this post.
Hope this will help some players who don't really have the skills to edit tables in a database :lol:
I'm the one and only. In heaven and on earth.
Image
hoegarden31
Rackie
Rackie
 
Posts: 150
Joined: Sun Nov 13, 2011 7:13 pm

Re: Admin panel for item mall

Postby Ultra on Mon Feb 27, 2012 5:27 pm

wont work..
Ultra
Rackie
Rackie
 
Posts: 226
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Admin panel for item mall

Postby merlon on Tue Feb 28, 2012 3:30 am

Ultra wrote:wont work..


Describe any errors and exactly how you install the module.
User avatar
merlon
Antares
Antares
 
Posts: 359
Joined: Fri Jul 09, 2010 2:15 pm

Re: Admin panel for item mall

Postby hoegarden31 on Tue Feb 28, 2012 10:10 am

The code is all made on the itemmall_v2 so if you haven't changed anything (all the database structure) then it should work perfectly. If it wouldn't work, then i wouldn't post it here, and share it :p
I'm the one and only. In heaven and on earth.
Image
hoegarden31
Rackie
Rackie
 
Posts: 150
Joined: Sun Nov 13, 2011 7:13 pm


Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 7 guests

cron