PageRenderTime 38ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/mp3act.27-7-2005/install.php

https://github.com/benbruscella/Grammafone
PHP | 393 lines | 351 code | 34 blank | 8 comment | 8 complexity | fa26f7ab4cff92c2508b66820d4d63ee MD5 | raw file
  1. <?php
  2. include("includes/mp3act_functions.php");
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  7. <head>
  8. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  9. <title><?php echo $GLOBALS['server_title']; ?> | Install Page</title>
  10. </head>
  11. <style>
  12. body{
  13. padding: 22px;
  14. margin:0;
  15. color: #333;
  16. background: #F0F0F0;
  17. text-align: center;
  18. font: 18px Times;
  19. }
  20. h2{
  21. font-size: 100%;
  22. margin:0;
  23. padding: 0 0 5px 0;
  24. }
  25. ul{
  26. list-style-type: none;
  27. }
  28. a{
  29. color: blue;
  30. }
  31. a:hover{
  32. /*color: #fff;
  33. background: #F21518;
  34. text-decoration: none;*/
  35. color: #F21518;
  36. }
  37. img{
  38. border: 0;
  39. }
  40. input,select{
  41. border: 1px solid #ccc;
  42. background: #f3f3f3;
  43. color: #333;
  44. font-size: 100%;
  45. padding: 2px 3px;
  46. }
  47. select{
  48. padding: 2px 0 2px 3px;
  49. }
  50. input:focus{
  51. border: 1px solid #999;
  52. background: #fff;
  53. color: #000;
  54. }
  55. input.btn{
  56. background: #244A79;
  57. color: #fff;
  58. padding: 2px;
  59. border-color: #0E2F58;
  60. font: normal 14px sans-serif;
  61. }
  62. input.btn:hover{
  63. background: #0E2F58;
  64. }
  65. .clear{
  66. clear: both;
  67. }
  68. .error{
  69. color: #E63838;
  70. font-weight: bold;
  71. }
  72. p#error{
  73. color: #f20000;
  74. font-weight: bold;
  75. }
  76. p.pad{
  77. padding: 0px 18px;
  78. }
  79. .right{
  80. float: right;
  81. }
  82. #wrap{
  83. background: #fff;
  84. border: 1px solid #ccc;
  85. text-align: left;
  86. padding: 0px;
  87. margin:0;
  88. }
  89. #header{
  90. position: relative;
  91. background: #0E2F58;
  92. height: 50px;
  93. color: #fff;
  94. padding: 15px 0 0px 15px;
  95. }
  96. #header h1{
  97. color: #9ABEE5;
  98. padding: 0;
  99. margin:0;
  100. font-size: 150%;
  101. }
  102. #topinfo{
  103. font-size: 90%;
  104. color: #666;
  105. text-align: left;
  106. padding: 0 0 4px 0;
  107. }
  108. </style>
  109. <body>
  110. <?php
  111. $step = 1;
  112. if($_GET[step])
  113. $step = $_GET[step];
  114. ?>
  115. <div id="topinfo">
  116. <div class="right">Installation Page</div>
  117. <strong>mp3act music box v1.1</strong>
  118. </div>
  119. <div id="wrap">
  120. <div id="header">
  121. <h1>mp3act Quick Install - Step <?php echo $step; ?></h1>
  122. </div>
  123. <p class='pad'>
  124. <?php
  125. switch($step){
  126. case 1:
  127. if(mp3act_connect()){
  128. $query = "SELECT user_id FROM mp3act_users";
  129. $result = @mysql_query($query);
  130. if(@mysql_num_rows($result) > 0){
  131. echo "<strong class='error'>It appears that you have already installed mp3act on this computer.</strong><br/><br/>";
  132. echo "<a href=\"http://$GLOBALS[http_server]$GLOBALS[uri_path]/\">Login to your mp3act server</a><br/>";
  133. }
  134. else{
  135. echo "<strong>Welcome to the mp3act installation page</strong><br/><br/>";
  136. echo "This is a very simple and easy installation. You'll be enjoying your music in no time at all. I swear.<br/><br/>";
  137. echo "<a href='install.php?step=2'>Proceed to Step 2 &raquo;</a>";
  138. }
  139. }
  140. else{
  141. echo "<strong class='error'>Unable to establish MySQL connection to database '".$GLOBALS[db_name]."'</strong><br/>";
  142. echo "Please make sure you have created the database and that the database settings in 'mp3act.conf' are correct.";
  143. }
  144. break;
  145. // Test to see if DB and user are set in conf file
  146. // Test DB connection
  147. // If good install Tables
  148. // Give instructions for setting permissions and external programs
  149. // mpg123, lame, Amazon API, php bin
  150. case 2:
  151. mp3act_connect();
  152. $querys['albums'] = "CREATE TABLE mp3act_albums (
  153. album_id int(11) NOT NULL auto_increment,
  154. album_name varchar(255) NOT NULL default '',
  155. artist_id int(255) NOT NULL default '0',
  156. album_genre varchar(50) default NULL,
  157. album_year smallint(6) NOT NULL default '0',
  158. album_art text NOT NULL,
  159. PRIMARY KEY (album_id)
  160. ) TYPE=MyISAM";
  161. $querys['artists'] = "CREATE TABLE mp3act_artists (
  162. artist_id int(11) NOT NULL auto_increment,
  163. artist_name varchar(255) default NULL,
  164. prefix varchar(7) NOT NULL default '',
  165. PRIMARY KEY (artist_id)
  166. ) TYPE=MyISAM";
  167. $querys['current'] = "CREATE TABLE mp3act_currentsong (
  168. song_id int(11) NOT NULL default '0',
  169. pl_id int(11) NOT NULL default '0',
  170. random tinyint(3) NOT NULL default '0'
  171. ) TYPE=MyISAM";
  172. $querys['genres'] = "CREATE TABLE mp3act_genres (
  173. genre_id int(11) NOT NULL auto_increment,
  174. genre varchar(25) NOT NULL default '',
  175. PRIMARY KEY (genre_id)
  176. ) TYPE=MyISAM";
  177. $querys['play_history'] = "CREATE TABLE mp3act_playhistory (
  178. play_id int(11) NOT NULL auto_increment,
  179. user_id int(6) default NULL,
  180. song_id int(11) default NULL,
  181. date_played datetime default NULL,
  182. PRIMARY KEY (play_id)
  183. ) TYPE=MyISAM";
  184. $querys['playlist'] = "
  185. CREATE TABLE mp3act_playlist (
  186. pl_id int(11) NOT NULL,
  187. song_id int(11) default NULL,
  188. user_id int(11) NOT NULL default '0',
  189. private tinyint(4) NOT NULL default '0',
  190. INDEX(user_id, private, pl_id)
  191. ) TYPE=MyISAM";
  192. $querys['playlists'] = "CREATE TABLE mp3act_saved_playlists (
  193. playlist_id int(11) NOT NULL auto_increment,
  194. user_id int(11) default NULL,
  195. private tinyint(3) default NULL,
  196. playlist_name varchar(255) default NULL,
  197. playlist_songs text,
  198. date_created datetime default NULL,
  199. time int(11) default NULL,
  200. songcount smallint(8) default NULL,
  201. PRIMARY KEY (playlist_id)
  202. ) TYPE=MyISAM";
  203. $querys['songs'] = "CREATE TABLE mp3act_songs (
  204. song_id int(11) NOT NULL auto_increment,
  205. artist_id int(11) NOT NULL default '0',
  206. album_id int(11) NOT NULL default '0',
  207. date_entered datetime default NULL,
  208. name varchar(255) default NULL,
  209. track smallint(6) NOT NULL default '0',
  210. length int(11) NOT NULL default '0',
  211. size int(11) NOT NULL default '0',
  212. bitrate smallint(6) NOT NULL default '0',
  213. type varchar(4) default NULL,
  214. numplays int(11) NOT NULL default '0',
  215. filename text,
  216. random tinyint(4) NOT NULL default '0',
  217. PRIMARY KEY (song_id)
  218. ) TYPE=MyISAM";
  219. $querys['stats'] = "CREATE TABLE mp3act_stats (
  220. num_artists smallint(5) unsigned NOT NULL default '0',
  221. num_albums smallint(5) unsigned NOT NULL default '0',
  222. num_songs mediumint(8) unsigned NOT NULL default '0',
  223. num_genres tinyint(3) unsigned NOT NULL default '0',
  224. total_time varchar(12) NOT NULL default '0',
  225. total_size varchar(10) NOT NULL default '0'
  226. ) TYPE=MyISAM";
  227. $querys['logins'] ="CREATE TABLE mp3act_logins (
  228. login_id int(11) NOT NULL auto_increment,
  229. user_id int(11) default NULL,
  230. date int(11) default NULL,
  231. md5 varchar(100) NOT NULL default '',
  232. PRIMARY KEY (login_id)
  233. ) TYPE=MyISAM";
  234. $querys['invites'] = "CREATE TABLE mp3act_invites (
  235. invite_id int(11) NOT NULL auto_increment,
  236. email varchar(100) NOT NULL default '',
  237. date_created datetime NOT NULL default '0000-00-00 00:00:00',
  238. invite_code varchar(255) NOT NULL default '',
  239. PRIMARY KEY (invite_id)
  240. ) TYPE=MyISAM";
  241. $querys['themes'] ="CREATE TABLE mp3act_themes (
  242. theme_id smallint(6) NOT NULL auto_increment,
  243. theme_name varchar(25) default NULL,
  244. color1 varchar(11) default NULL,
  245. color2 varchar(11) default NULL,
  246. color3 varchar(11) default NULL,
  247. color4 varchar(11) default NULL,
  248. color5 varchar(11) default NULL,
  249. theme_user_id smallint(6) default NULL,
  250. PRIMARY KEY (theme_id)
  251. ) TYPE=MyISAM";
  252. $querys['theme1'] = "INSERT INTO `mp3act_themes` VALUES (NULL, 'default blue', '#0E2F58', '#244A79', '#416899', '#9ABEE5', '#F48603', 0)";
  253. $querys['theme2'] = "INSERT INTO `mp3act_themes` VALUES (NULL, 'green', '#194904', '#2E6D12', '#60A041', '#89C86E', '#3873A1', 0)";
  254. $querys['theme3'] = "INSERT INTO `mp3act_themes` VALUES (NULL, 'red', '#6D0C11', '#912328', '#B44146', '#CEB78B', '#7A643A', 0)";
  255. $querys['users'] = "CREATE TABLE mp3act_users (
  256. user_id int(11) NOT NULL auto_increment,
  257. username varchar(100) NOT NULL default '',
  258. firstname varchar(100) NOT NULL default '',
  259. lastname varchar(100) NOT NULL default '',
  260. password varchar(255) NOT NULL default '',
  261. accesslevel tinyint(4) NOT NULL default '0',
  262. date_created datetime NOT NULL default '0000-00-00 00:00:00',
  263. active tinyint(4) NOT NULL default '0',
  264. email varchar(255) NOT NULL default '',
  265. default_mode varchar(50) NOT NULL default '',
  266. default_bitrate int(11) NOT NULL default '0',
  267. default_stereo varchar(50) NOT NULL default '',
  268. md5 varchar(255) NOT NULL default '',
  269. last_ip varchar(50) NOT NULL default '',
  270. last_login datetime default NULL,
  271. theme_id smallint(6) NOT NULL default '1',
  272. PRIMARY KEY (user_id)
  273. ) TYPE=MyISAM";
  274. $querys['settings'] = "CREATE TABLE mp3act_settings (
  275. id int(3) NOT NULL auto_increment,
  276. version varchar(15) NOT NULL default '',
  277. invite_mode tinyint(4) NOT NULL default '0',
  278. upload_path varchar(255) NOT NULL default '',
  279. amazonid varchar(255) NOT NULL default '',
  280. downloads tinyint(4) NOT NULL default '0',
  281. sample_mode tinyint(2) NOT NULL default '0',
  282. mp3bin varchar(100) NOT NULL default '',
  283. lamebin varchar(100) NOT NULL default '',
  284. phpbin varchar(100) NOT NULL default '',
  285. PRIMARY KEY (id)
  286. ) TYPE=MyISAM";
  287. $querys['settingsinfo'] = "INSERT INTO `mp3act_settings` VALUES (NULL,'1.1',0, '', '', 0,0,'','','')";
  288. echo "<strong>Creating mp3act Database Tables....</strong><br/><br/>";
  289. // CREATE TABLES
  290. $error = 0;
  291. foreach($querys as $key=>$query){
  292. if(mysql_query($query)){
  293. }
  294. else{
  295. $error = 1;
  296. }
  297. }
  298. if(!$error){
  299. echo "<strong>mp3act Databases Installed Successfully</strong<br/><br/>";
  300. }
  301. echo "<a href='install.php?step=3'>Proceed to Step 3 &raquo;</a>";
  302. break;
  303. case 3:
  304. ?>
  305. <strong class='error'>Take a Moment to Configure Your mp3act Installation.</strong><br/> You don't have to set these now. They are accessible from the Admin menu. However some of the options are neccessary for some features to work.<br/>
  306. <form method='post' action="install.php?step=4">
  307. <p class='pad'>
  308. <strong>Invitation for Registration</strong><br/>(Users are required to be invited to register)<br/><select name='invite'><option value='0' >Not Required</option><option value='1'>Required</option></select><br/><br/>
  309. <strong>Sample Mode</strong><br/>(play 1/4 of each song)<br/><select name='sample_mode'><option value='0'>Sample Mode OFF</option><option value='1' >Sample Mode ON</option></select><br/><br/>
  310. <strong>Music Downloads</strong><br/>(Rules for Users Downloading Music)<br/><select name='downloads'><option value='0' >Not Allowed</option><option value='1' >Allowed for All</option><option value='2' >Allowed with Permission</option></select><br/><br/>
  311. <strong>Amazon API Key</strong><br/>(needed for downloading Album Art) <a href='http://www.amazon.com/webservices/' target='_new'>Obtain Key</a><br/><input type='text' size='30' name='amazonid' /><br/><br/>
  312. <strong>Path to MP3 Player</strong><br/>(ex. /usr/bin/mpg123)<br/><input type='text' size='30' name='mp3bin' /><br/><br/>
  313. <strong>Path to Lame Encoder</strong><br/>(ex. /usr/bin/lame)<br/><input type='text' size='30' name='lamebin' /><br/><br/>
  314. <strong>Path to PHP-CLI Binary</strong><br/>(ex. /usr/bin/php)<br/><input type='text' size='30' name='phpbin' /><br/><br/>
  315. <input type='submit' value='save settings and continue &raquo;' class='btn' />
  316. </p>
  317. </form>
  318. <?php
  319. break;
  320. case 4:
  321. mp3act_connect();
  322. $query = "UPDATE mp3act_settings SET invite_mode=$_POST[invite],sample_mode=$_POST[sample_mode],downloads=$_POST[downloads],amazonid=\"$_POST[amazonid]\",upload_path=\"$_POST[upload_path]\",mp3bin=\"$_POST[mp3bin]\",lamebin=\"$_POST[lamebin]\",phpbin=\"$_POST[phpbin]\" WHERE id=1";
  323. mysql_query($query);
  324. echo "<strong>Settings Saved....</strong><br/><br/>";
  325. echo "<strong>Installation Successful!</strong><br/><br/>";
  326. if(!ini_get('allow_url_fopen')){
  327. echo "<strong class='error'>WARNING: </strong>Need to Set allow_url_fopen to 'On' in your php.ini file.<br/><br/>";
  328. }
  329. if(!is_writable($GLOBALS['abs_path']."/art/")){
  330. echo "<strong class='error'>WARNING: </strong>The /art/ directory is currently not writable. Please change the permissions on this directory if you wish to use Album Art.<br/><br/>";
  331. }
  332. echo "<a href=\"http://$GLOBALS[http_server]$GLOBALS[uri_path]/\">Login to your new mp3act server</a><br/>";
  333. $random_password = substr(md5(uniqid(microtime())), 0, 6);
  334. $query = "INSERT INTO `mp3act_users` VALUES (NULL, 'admin', 'Admin', 'User', PASSWORD(\"$random_password\"), 10, NOW(), 1, '', 'streaming', 0, 's', '21232f297a57a5a743894a0e4a801fc3', '', '0000-00-00 00:00:00', 1)";
  335. mysql_query($query);
  336. echo "<br/><strong>Username:</strong> Admin<br/><strong>Password:</strong> $random_password (Please change this password as soon as you login.)<br/><br/>";
  337. echo "To add music to the database, choose the 'Admin' tab and click on 'Add Music to Database'";
  338. break;
  339. } // END SWITCH
  340. ?>
  341. </p>
  342. </div>
  343. </body>
  344. </html>