| 1 | <?php require_once('conf/sample.user.conf.php'); ?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 3 | |
|---|
| 4 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 5 | |
|---|
| 6 | <head> |
|---|
| 7 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|---|
| 8 | <title><?=TITLE?></title> |
|---|
| 9 | <link rel="stylesheet" type="text/css" href="<?=DIR_CSS_ESTIL?>" media="all" /> |
|---|
| 10 | <style type="text/css" media="screen"> |
|---|
| 11 | .input_row{ |
|---|
| 12 | height: 20px; |
|---|
| 13 | width: 100%; |
|---|
| 14 | } |
|---|
| 15 | .input_row > div { |
|---|
| 16 | float: left; |
|---|
| 17 | } |
|---|
| 18 | .input_cont{ |
|---|
| 19 | height: 20px; |
|---|
| 20 | padding-top: 6px; |
|---|
| 21 | font-size:12px; |
|---|
| 22 | width: 80px; |
|---|
| 23 | text-align: left; |
|---|
| 24 | } |
|---|
| 25 | </style> |
|---|
| 26 | </head> |
|---|
| 27 | |
|---|
| 28 | <body> |
|---|
| 29 | <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;"> |
|---|
| 30 | Install |
|---|
| 31 | </div> |
|---|
| 32 | <?php |
|---|
| 33 | function bool2string($val){ |
|---|
| 34 | if($val){ return "true"; } return "false"; |
|---|
| 35 | } |
|---|
| 36 | function check_required_fields($_REQUEST){ |
|---|
| 37 | $retv = FALSE; |
|---|
| 38 | $retv = $retv || strlen($_REQUEST['urlbasef']) == 0; |
|---|
| 39 | $retv = $retv || strlen($_REQUEST['webauthf']) == 0; |
|---|
| 40 | $retv = $retv || strlen($_REQUEST['authdirf']) == 0; |
|---|
| 41 | $retv = $retv || strlen($_REQUEST['portnumf']) == 0; |
|---|
| 42 | $retv = $retv || strlen($_REQUEST['hostf'] ) == 0; |
|---|
| 43 | $retv = $retv || strlen($_REQUEST['userf'] ) == 0; |
|---|
| 44 | $retv = $retv || strlen($_REQUEST['passwdf'] ) == 0; |
|---|
| 45 | $retv = $retv || strlen($_REQUEST['confirmf']) == 0; |
|---|
| 46 | $retv = $retv || strlen($_REQUEST['torrdirf']) == 0; |
|---|
| 47 | $retv = $retv || strlen($_REQUEST['datadirf']) == 0; |
|---|
| 48 | $retv = $retv || strlen($_REQUEST['appdirf'] ) == 0; |
|---|
| 49 | $retv = $retv || strcmp($_REQUEST['passwdf'], $_REQUEST['confirmf']) != 0; |
|---|
| 50 | return !$retv; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | $conf_file = 'conf/user.conf.php'; |
|---|
| 54 | // if(file_exists(DB_FILE)) |
|---|
| 55 | // { |
|---|
| 56 | // echo '<div id="principal" class="principal" style="width: 500px;"><div style="font-size: 11px; margin-bottom: 12px; font-weight: bold;">'; |
|---|
| 57 | // echo 'wTorrent has already been configured.<br /> If you wish to re-run the install, please delete or move your db file.'; |
|---|
| 58 | // echo '</div></div></body></html>'; |
|---|
| 59 | // die(); |
|---|
| 60 | // } |
|---|
| 61 | if(isset($_REQUEST['create'])) |
|---|
| 62 | { |
|---|
| 63 | echo '<div class="messages" style="display: block; margin-bottom: 10px;">'; |
|---|
| 64 | if(!check_required_fields($_REQUEST)){ |
|---|
| 65 | echo "<p><b>Please, Fill in the form</b></p>"; |
|---|
| 66 | echo "<table>"; |
|---|
| 67 | echo "<tr>"; |
|---|
| 68 | echo "<td>urlbasef" . "</td><td>---></td><td>" . $_REQUEST["urlbasef"] . "</td>"; |
|---|
| 69 | echo "</tr><tr>"; |
|---|
| 70 | echo "<td>webauthf" . "</td><td>---></td><td>" . $_REQUEST["webauthf"] . "</td>"; |
|---|
| 71 | echo "</tr><tr>"; |
|---|
| 72 | echo "<td>authdirf" . "</td><td>---></td><td>" . $_REQUEST["authdirf"] . "</td>"; |
|---|
| 73 | echo "</tr><tr>"; |
|---|
| 74 | echo "<td>portnumf" . "</td><td>---></td><td>" . $_REQUEST["portnumf"] . "</td>"; |
|---|
| 75 | echo "</tr><tr>"; |
|---|
| 76 | echo "<td>hostf" . "</td><td>---></td><td>" . $_REQUEST["hostf"] . "</td>"; |
|---|
| 77 | echo "</tr><tr>"; |
|---|
| 78 | echo "<td>userf" . "</td><td>---></td><td>" . $_REQUEST["userf"] . "</td>"; |
|---|
| 79 | echo "</tr><tr>"; |
|---|
| 80 | echo "<td>passwdf" . "</td><td>---></td><td>" . $_REQUEST["passwdf"] . "</td>"; |
|---|
| 81 | echo "</tr><tr>"; |
|---|
| 82 | echo "<td>confirmf" . "</td><td>---></td><td>" . $_REQUEST["confirmf"] . "</td>"; |
|---|
| 83 | echo "</tr><tr>"; |
|---|
| 84 | echo "<td>torrdirf" . "</td><td>---></td><td>" . $_REQUEST["torrdirf"] . "</td>"; |
|---|
| 85 | echo "</tr><tr>"; |
|---|
| 86 | echo "<td>datadirf" . "</td><td>---></td><td>" . $_REQUEST["datadirf"] . "</td>"; |
|---|
| 87 | echo "</tr><tr>"; |
|---|
| 88 | echo "<td>appdirf" . "</td><td>---></td><td>" . $_REQUEST["appdirf"] . "</td>"; |
|---|
| 89 | echo "</tr>"; |
|---|
| 90 | echo "</table></div>"; |
|---|
| 91 | die(); |
|---|
| 92 | }else{ |
|---|
| 93 | if(!file_exists($conf_file)){ |
|---|
| 94 | // Check password |
|---|
| 95 | if($_REQUEST["passwdf"] != $_REQUEST["confirmf"]){ |
|---|
| 96 | echo "Password and confirmation do not match.</div>"; |
|---|
| 97 | die(); |
|---|
| 98 | } |
|---|
| 99 | if(!($fd = fopen($conf_file, 'w'))){ |
|---|
| 100 | echo "There was an error with the permissions.<br />Run as root in a shell:</br><p style='font-family: Courier, \"Courier New\"'>chown -R [unixUser].[unixUser] [wTorrentFolder]; chmod -R a+w [wTorrentFolder]</p></div>"; |
|---|
| 101 | die(); |
|---|
| 102 | } |
|---|
| 103 | $data = "<?php\n/*\nThis file is part of wTorrent.\n\nwTorrent is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3 of the License, or\n(at your option) any later version.\n\nwTorrent is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\n\nModified version of class done by David Marco Martinez\n*/ |
|---|
| 104 | \n\n// Base URL of application (where index.php is) \ndefine( 'URL', '" . $_REQUEST['urlbasef'] . "' );\ndefine( 'BASE', '" . $_REQUEST['urlbasef'] . "' );\n\n// SQLite database file (set folder permision 0777 or chmod to httpd server) (wTorrent will create database when running install.php)\ndefine( 'DB_FILE', '" . $_REQUEST['databasef'] . "');\n\n// Host or IP to connect to rTorrent\ndefine( 'RT_HOST', '" . $_REQUEST['hostf'] . "');\ndefine( 'RT_PORT', " . $_REQUEST['portnumf'] . ");\ndefine( 'RT_DIR', '" . $_REQUEST['authdirf'] . "');\ndefine( 'RT_AUTH', " . bool2string($_REQUEST['webauthf'] == 1) . ");\ndefine( 'RT_USER', '" . $_REQUEST['userf'] . "');\ndefine( 'RT_PASSWD', '" . $_REQUEST['passwdf'] . "');\n// where to use multicall or not\n// if wTorrent makes your rtorrent crash, set this to true\ndefine( 'NO_MULTICALL', true);\n\n// Directory in which to save uploaded .torrent files (set folder permision 0777 or chmod to httpd server)\ndefine( 'DIR_TORRENTS', '" . $_REQUEST['torrdirf'] . "');\n\n// Full path to application directory (where index.php is)\ndefine( 'DIR_EXEC', '" . $_REQUEST['appdirf'] . "');\n\n// Permision to set for uploaded .torrent files (don't touch unless you know)\n\n// Default location to save downloaded files (can be set for every uploaded .torrent on the ui) \ndefine( 'DIR_DOWNLOAD', '" . $_REQUEST['datadirf'] . "');\n\n"; |
|---|
| 105 | fwrite($fd, $data); |
|---|
| 106 | // require_once($conf_file); |
|---|
| 107 | fclose($fd); |
|---|
| 108 | echo "Configuration file created!<p>Make any manual changes to $conf_file and click finish.</p></div>"; |
|---|
| 109 | echo "<form action=\"install.php\" method=\"POST\">"; |
|---|
| 110 | echo "<input type=\"hidden\" value=\"" . $_REQUEST['userf'] . "\" name=\"userf\" />"; |
|---|
| 111 | echo "<input type=\"hidden\" value=\"" . $_REQUEST['passwdf'] . "\" name=\"passwdf\" />"; |
|---|
| 112 | echo "<div style=\"width: 400px; margin: 0 auto 0 auto;\"><input type=\"submit\" value=\"Finish\" name=\"create\" /></div>"; |
|---|
| 113 | echo "</form>"; |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | die(); |
|---|
| 117 | }else{ |
|---|
| 118 | echo "Configuration file was already present!"; |
|---|
| 119 | echo "<p>Make any manual changes to $conf_file and click finish.</p></div>"; |
|---|
| 120 | echo "<form action=\"install.php\" method=\"POST\">"; |
|---|
| 121 | echo "<input type=\"hidden\" value=\"" . RT_USER . "\" name=\"userf\" />"; |
|---|
| 122 | echo "<input type=\"hidden\" value=\"" . RT_PASSWD . "\" name=\"passwdf\" />"; |
|---|
| 123 | echo "<div style=\"width: 400px; margin: 0 auto 0 auto;\"><input type=\"submit\" value=\"Finish\" name=\"create\" /></div>"; |
|---|
| 124 | echo "</form>"; |
|---|
| 125 | die(); |
|---|
| 126 | } |
|---|
| 127 | // if($_REQUEST['userf'] != '' && $_REQUEST['passwdf'] != '') |
|---|
| 128 | // { |
|---|
| 129 | // $db = new SQLiteDatabase(DB_FILE); |
|---|
| 130 | // if(is_object($db)) |
|---|
| 131 | // { |
|---|
| 132 | // $sql_create = "CREATE TABLE tor_passwd(id integer primary key, user text, passwd text, admin integer, dir text, force_dir integer);"; |
|---|
| 133 | // $sql_insert = "INSERT INTO tor_passwd VALUES(1,'" . $_REQUEST['userf'] . "','" . md5($_REQUEST['passwdf']) . "',1, '', 0);"; |
|---|
| 134 | // $sql_create_torrents = "create table torrents(hash string, user int, private int);"; |
|---|
| 135 | // $sql_create_feeds = "CREATE TABLE feeds(id integer primary key, url text, user integer);"; |
|---|
| 136 | // $sql_create_cookies = "CREATE TABLE cookie(id integer primary key, userid integer, value text, hostname text);"; |
|---|
| 137 | // $res1 = $db->query($sql_create); |
|---|
| 138 | // $res2 = $db->query($sql_insert); |
|---|
| 139 | // $res3 = $db->query($sql_create_torrents); |
|---|
| 140 | // $res4 = $db->query($sql_create_feeds); |
|---|
| 141 | // $res5 = $db->query($sql_create_cookies); |
|---|
| 142 | // if($res1 !== false && $res2 !== false) |
|---|
| 143 | // echo 'Database succesfully created, please delete install.php and enjoy wTorrent'; |
|---|
| 144 | // else |
|---|
| 145 | // echo 'Error during creation/insertion of user into the database, please check that the dir has correct permisions'; |
|---|
| 146 | // |
|---|
| 147 | // } else { |
|---|
| 148 | // echo 'Error trying to access database, plase check that you have compiled php with sqlite support'; |
|---|
| 149 | // } |
|---|
| 150 | // } else { |
|---|
| 151 | // echo 'Error, you must fill the form'; |
|---|
| 152 | // } |
|---|
| 153 | } |
|---|
| 154 | echo '</div>'; |
|---|
| 155 | } |
|---|
| 156 | // else if(isset($_REQUEST['update'])) |
|---|
| 157 | // { |
|---|
| 158 | // echo '<div class="messages">'; |
|---|
| 159 | // $db = new SQLiteDatabase(DB_FILE); |
|---|
| 160 | // if(is_object($db)) |
|---|
| 161 | // { |
|---|
| 162 | // $sql_create_torrents = "CREATE TABLE feeds(id integer primary key, url text, user integer);"; |
|---|
| 163 | // $res = $db->query($sql_create_torrents); |
|---|
| 164 | // if($res !== false) |
|---|
| 165 | // echo 'Update complete, please delete install.php'; |
|---|
| 166 | // else |
|---|
| 167 | // echo 'Error performing update, please check wTorrent for correct installation and/or reinstall'; |
|---|
| 168 | // } else |
|---|
| 169 | // echo 'Could not connect to database, please check configuration'; |
|---|
| 170 | // echo '</div>'; |
|---|
| 171 | // } |
|---|
| 172 | ?> |
|---|
| 173 | <div id="principal" class="principal" style="width: 500px;"> |
|---|
| 174 | <div id="contingut" class="contingut" style="width:450px; padding: 20px; padding-bottom: 0px; margin-top: 5px;"> |
|---|
| 175 | <div style="font-size: 11px; margin-bottom: 12px; font-weight: bold;"> |
|---|
| 176 | Welcome to wTorrent!<br /> |
|---|
| 177 | Please input the information required |
|---|
| 178 | </div><hr noshade /><br /> |
|---|
| 179 | <form action="install2.php" method="POST"> |
|---|
| 180 | <div class="input_row"> |
|---|
| 181 | <div class="input_cont"> |
|---|
| 182 | <b>Base URL:</b> |
|---|
| 183 | </div> |
|---|
| 184 | <div> |
|---|
| 185 | <input type="text" size="40" value="<?php echo URL ?>" name="urlbasef" /> |
|---|
| 186 | </div> |
|---|
| 187 | </div><br /><hr noshade /><br /> |
|---|
| 188 | <div class="input_row"> |
|---|
| 189 | <div class="input_cont"> |
|---|
| 190 | <b>Server Auth:</b> |
|---|
| 191 | </div> |
|---|
| 192 | <div> |
|---|
| 193 | <input type="checkbox" value="<?php if(RT_AUTH){echo '1 checked';}else{echo '0';} ?>" checked name="webauthf" /> |
|---|
| 194 | </div> |
|---|
| 195 | <div class="input_cont" style="padding-left: 5px;"><b>DIR:</b></div><div><input type="text" size="10" value="<?php echo RT_DIR ?>" name="authdirf" /></div> |
|---|
| 196 | </div><br /> |
|---|
| 197 | <div class="input_row"><div class="input_cont"><b>Port:</b></div><div><input style="text-align: right;" type="text" size="5" value="<?php echo RT_PORT ?>" name="portnumf" /></div></div><br /> |
|---|
| 198 | <div class="input_row"><div class="input_cont"><b>Host:</b></div><div><input type="text" value="<?php echo RT_HOST ?>" name="hostf" /></div></div><br /><hr noshade /><br /> |
|---|
| 199 | <div class="input_row"><div class="input_cont"><b>User:</b></div><div><input type="text" value="<?php echo RT_USER ?>" name="userf" /></div></div><br /> |
|---|
| 200 | <div class="input_row"><div class="input_cont"><b>Password:</b></div><div> <input type="password" value="<?php echo RT_PASSWD ?>" name="passwdf" /></div></div><br /> |
|---|
| 201 | <div class="input_row"><div class="input_cont"><b>Confirm:</b></div><div> <input type="password" name="confirmf" /></div></div><br /><hr noshade /><br /> |
|---|
| 202 | <div class="input_row"><div class="input_cont"><b>Torrent dir:</b></div><div> <input type="text" size="40" value="<?php echo DIR_TORRENTS ?>" name="torrdirf" /></div></div><br /> |
|---|
| 203 | <div class="input_row"><div class="input_cont"><b>Data dir:</b></div><div> <input type="text" size="40" value="<?php echo DIR_DOWNLOAD ?>" name="datadirf" /></div></div><br /> |
|---|
| 204 | <div class="input_row"><div class="input_cont"><b>wTorrent dir:</b></div><div> <input type="text" size="40" value="<?php echo DIR_EXEC ?>" name="appdirf" /></div></div><br /> |
|---|
| 205 | <div class="input_row"> |
|---|
| 206 | <div class="input_cont"> |
|---|
| 207 | <b>DB file:</b> |
|---|
| 208 | </div> |
|---|
| 209 | <div> |
|---|
| 210 | <input type="text" value="<?php echo DB_FILE ?>" name="databasef" /> |
|---|
| 211 | </div> |
|---|
| 212 | </div><br /><br /> |
|---|
| 213 | |
|---|
| 214 | <div style="padding-bottom: 10px;"><input type="submit" value="Create" name="create" /></div> |
|---|
| 215 | <!-- <div style="padding-bottom: 10px;"><input type="submit" value="Update (only 20071014 and previous versions users)" name="update" /></div> --> |
|---|
| 216 | </form> |
|---|
| 217 | </div> |
|---|
| 218 | </div> |
|---|
| 219 | </body> |
|---|
| 220 | |
|---|
| 221 | </html> |
|---|