Advertisement
Guest User

player_shops_install.php

a guest
May 3rd, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. <?php
  2.  
  3. require(__DIR__.'/globals.php');
  4.  
  5. $tb1 = $db->num_rows($db->query("SHOW TABLES LIKE 'user_shopitems'"));
  6. $tb2 = $db->num_rows($db->query("SHOW TABLES LIKE 'usershops'"));
  7.  
  8. if($tb1 && $tb2)
  9.     echo "<span style='color:red;font-weight:bold;font-size:10px;'>Installer has detected that you have both installer files.</span>";
  10. else if($tb1 && !$tb2)
  11.     echo "<span style='color:red;font-weight:bold;font-size:10px;'>Intaller detected that you already have a table called shopitems</span>";
  12. else if(!$tb1 && $tb2)
  13.     echo "<span style='color:red;font-weight:bold;font-size:10px;'>Installer detected that you already have a table called usershops</span>";
  14. else
  15. {
  16.     echo "Attempting to install first table..<br /><br />";
  17.     $insert = $db->query("
  18.         CREATE TABLE IF NOT EXISTS `user_shopitems` (
  19.             `id` int(11) NOT NULL AUTO_INCREMENT,
  20.             `stype` enum('item','crystals','donatordays') NOT NULL,
  21.             `selling` int(20) NOT NULL DEFAULT '0',
  22.             `sqty` int(20) NOT NULL,
  23.             `tprice` int(20) NOT NULL,
  24.             `sID` int(11) NOT NULL,
  25.             PRIMARY KEY (`id`)
  26.         ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
  27.     if(!$insert)
  28.         echo "There was a issue with install.<br />".$db->error();
  29.     else
  30.     {
  31.         echo "Table one installed successfully.<br />";
  32.         echo "Attempting to install the second table..<br /><br />";
  33.         $insert = $db->query("
  34.             CREATE TABLE IF NOT EXISTS `usershops` (
  35.                 `id` int(11) NOT NULL AUTO_INCREMENT,
  36.                 `name` varchar(20) NOT NULL,
  37.                 `desc` varchar(100) NOT NULL,
  38.                 `pic` varchar(120) NOT NULL DEFAULT 'images/noimg.png',
  39.                 `status` int(1) NOT NULL DEFAULT '1',
  40.                 `owner` int(11) NOT NULL DEFAULT '0',
  41.                 `cdate` int(20) NOT NULL DEFAULT '0',
  42.                 PRIMARY KEY (`id`)
  43.             ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
  44.         if(!$insert)
  45.             echo "There was a issue with install.<br />".$db->error();
  46.         else
  47.         {
  48.             echo "Table two installed successfully.<br /><br />";
  49.             echo "Intall complete attempting to remove intaller..";
  50.             unlink('./player_shops_install.php');
  51.             $success = !file_exists('./player_shops_install.php');
  52.             echo "<span style='color: ". ($success ? "green;'>Succeeded" : "red;'>Failed"). "</span><br />";
  53.             echo '<meta http-equiv="refresh" content="8; url=myshop.php">';
  54.             $h->endpage();
  55.             exit;
  56.             if(!$success)
  57.             echo "
  58.             <span style='color:red;font-weight:bold;font-size:10px;'>
  59.                 Since the auto deletion of the instaltion file failed i strongly suggest you delete it manually.
  60.             </span>";
  61.         }
  62.     }
  63. }
  64. $h->endpage();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement