| 1 | <?php |
|---|
| 2 | require_once( 'conf/user.conf.php' ); |
|---|
| 3 | require_once( 'conf/system.conf.php' ); |
|---|
| 4 | ?> |
|---|
| 5 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 6 | |
|---|
| 7 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 8 | |
|---|
| 9 | <head> |
|---|
| 10 | <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-15" /> |
|---|
| 11 | <title><?=TITLE?></title> |
|---|
| 12 | <link rel="stylesheet" type="text/css" href="<?=DIR_CSS_ESTIL?>" media="all" /> |
|---|
| 13 | </head> |
|---|
| 14 | |
|---|
| 15 | <body> |
|---|
| 16 | <div style="font-family: georgia; font-size: 20px; text-align: center; font-weight: bold; padding-top: 8px; margin: 0px auto; background-color: #ffffff; width: 300px; height: 30px; top: 0px; border-bottom: 1px solid #d4d4d4; border-left: 1px solid #d4d4d4; border-right: 1px solid #d4d4d4;"> |
|---|
| 17 | Install |
|---|
| 18 | </div> |
|---|
| 19 | <?php |
|---|
| 20 | if(file_exists(DB_FILE)) |
|---|
| 21 | { |
|---|
| 22 | echo '<div id="principal" class="principal" style="width: 500px;"><div style="font-size: 11px; margin-bottom: 12px; font-weight: bold;">'; |
|---|
| 23 | echo 'wTorrent has already been configured.<br /> If you wish to re-run the install, please delete or move your db file.'; |
|---|
| 24 | echo '</div></div></body></html>'; |
|---|
| 25 | die(); |
|---|
| 26 | } |
|---|
| 27 | if(isset($_REQUEST['create'])) |
|---|
| 28 | { |
|---|
| 29 | echo '<div class="messages" style="display: block; margin-bottom: 10px;">'; |
|---|
| 30 | if($_REQUEST['userf'] != '' && $_REQUEST['passwdf'] != '') |
|---|
| 31 | { |
|---|
| 32 | $db = new SQLiteDatabase(DB_FILE); |
|---|
| 33 | if(is_object($db)) |
|---|
| 34 | { |
|---|
| 35 | $sql_create = "CREATE TABLE tor_passwd(id integer primary key, user text, passwd text, admin integer, dir text, force_dir integer);"; |
|---|
| 36 | $sql_insert = "INSERT INTO tor_passwd VALUES(1,'" . $_REQUEST['userf'] . "','" . md5($_REQUEST['passwdf']) . "',1, '', 0);"; |
|---|
| 37 | $sql_create_torrents = "create table torrents(hash string, user int, private int);"; |
|---|
| 38 | $sql_create_feeds = "CREATE TABLE feeds(id integer primary key, url text, user integer);"; |
|---|
| 39 | $sql_create_cookies = "CREATE TABLE cookie(id integer primary key, userid integer, value text, hostname text);"; |
|---|
| 40 | $res1 = $db->query($sql_create); |
|---|
| 41 | $res2 = $db->query($sql_insert); |
|---|
| 42 | $res3 = $db->query($sql_create_torrents); |
|---|
| 43 | $res4 = $db->query($sql_create_feeds); |
|---|
| 44 | $res5 = $db->query($sql_create_cookies); |
|---|
| 45 | if($res1 !== false && $res2 !== false) |
|---|
| 46 | echo 'Database succesfully created, please delete install.php and enjoy wTorrent'; |
|---|
| 47 | else |
|---|
| 48 | echo 'Error during creation/insertion of user into the database, please check that the dir has correct permisions'; |
|---|
| 49 | |
|---|
| 50 | } else { |
|---|
| 51 | echo 'Error trying to access database, plase check that you have compiled php with sqlite support'; |
|---|
| 52 | } |
|---|
| 53 | } else { |
|---|
| 54 | echo 'Error, you must fill the form'; |
|---|
| 55 | } |
|---|
| 56 | echo '</div>'; |
|---|
| 57 | die(); |
|---|
| 58 | } |
|---|
| 59 | else if(isset($_REQUEST['update'])) |
|---|
| 60 | { |
|---|
| 61 | echo '<div class="messages">'; |
|---|
| 62 | $db = new SQLiteDatabase(DB_FILE); |
|---|
| 63 | if(is_object($db)) |
|---|
| 64 | { |
|---|
| 65 | $sql_create_torrents = "CREATE TABLE feeds(id integer primary key, url text, user integer);"; |
|---|
| 66 | $res = $db->query($sql_create_torrents); |
|---|
| 67 | if($res !== false) |
|---|
| 68 | echo 'Update complete, please delete install.php'; |
|---|
| 69 | else |
|---|
| 70 | echo 'Error performing update, please check wTorrent for correct installation and/or reinstall'; |
|---|
| 71 | } else |
|---|
| 72 | echo 'Could not connect to database, please check configuration'; |
|---|
| 73 | echo '</div>'; |
|---|
| 74 | } |
|---|
| 75 | ?> |
|---|
| 76 | <div id="principal" class="principal" style="width: 500px;"> |
|---|
| 77 | <div id="contingut" class="contingut" style="width:450px; padding: 20px; padding-bottom: 0px; margin-top: 5px;"> |
|---|
| 78 | <div style="font-size: 11px; margin-bottom: 12px; font-weight: bold;"> |
|---|
| 79 | Welcome to wTorrent!<br /> |
|---|
| 80 | Please input your desired username/password |
|---|
| 81 | </div> |
|---|
| 82 | <form action="install.php" method="POST"> |
|---|
| 83 | <div style="height: 20px; width: 100%;"><div style="height: 20px; padding-top: 6px; font-size:12px; width: 80px; float: left; text-align: left;"><b>User:</b></div><div style="float: left;"><input type="text" name="userf" /></div></div><br /> |
|---|
| 84 | <div style="height: 20px; width: 100%;"><div style="height: 20px; padding-top: 6px; font-size: 12px; width: 80px; float: left; text-align: left;"><b>Password:</b></div><div style="float: left;"> <input type="text" name="passwdf" /></div></div><br /> |
|---|
| 85 | <div style="padding-bottom: 10px;"><input type="submit" value="Create" name="create" /></div> |
|---|
| 86 | <!-- <div style="padding-bottom: 10px;"><input type="submit" value="Update (only 20071014 and previous versions users)" name="update" /></div> --> |
|---|
| 87 | </form> |
|---|
| 88 | </div> |
|---|
| 89 | </div> |
|---|
| 90 | </body> |
|---|
| 91 | |
|---|
| 92 | </html> |
|---|