Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
<?php
2
 
3
/*************************************************************
4
*  TorrentFlux - PHP Torrent Manager
5
*  www.torrentflux.com
6
**************************************************************/
7
/*
8
    This file is part of TorrentFlux.
9
 
10
    TorrentFlux is free software; you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation; either version 2 of the License, or
13
    (at your option) any later version.
14
 
15
    TorrentFlux is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with TorrentFlux; if not, write to the Free Software
22
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
*/
24
 
25
 
26
include_once("config.php");
27
include_once("functions.php");
28
 
29
$messages = "";
30
 
31
// set refresh option into the session cookie
32
if(array_key_exists("pagerefresh", $_GET))
33
{
34
    if($_GET["pagerefresh"] == "false")
35
    {
36
        $_SESSION['prefresh'] = false;
37
        header("location: index.php");
38
        exit();
39
    }
40
 
41
    if($_GET["pagerefresh"] == "true")
42
    {
43
        $_SESSION["prefresh"] = true;
44
        header("location: index.php");
45
        exit();
46
    }
47
}
48
// Check to see if QManager is running if not Start it.
49
if (checkQManager() == 0 )
50
{
51
    if ($cfg["AllowQueing"])
52
    {
53
        if (is_dir($cfg["path"]) && is_writable($cfg["path"]))
54
        {
55
            AuditAction($cfg["constants"]["QManager"], "QManager Not Running");
56
            sleep(2);
57
            startQManager($cfg["maxServerThreads"],$cfg["maxUserThreads"],$cfg["sleepInterval"]);
58
            sleep(2);
59
        }
60
        else
61
        {
62
            AuditAction($cfg["constants"]["error"], "Error starting Queue Manager -- TorrentFlux settings are not correct (path is not valid)");
63
            if (IsAdmin())
64
            {
65
                header("location: admin.php?op=configSettings");
66
                exit();
67
            }
68
            else
69
            {
70
                $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not valid) -- please contact an admin.<br>";
71
            }
72
        }
73
    }
74
}
75
 
76
$torrent = getRequestVar('torrent');
77
 
78
if(!empty($torrent))
79
{
80
    include_once("AliasFile.php");
81
 
82
    if ($cfg["enable_file_priority"])
83
    {
84
        include_once("setpriority.php");
85
        // Process setPriority Request.
86
        setPriority($torrent);
87
    }
88
 
89
    $spo = getRequestVar('setPriorityOnly');
90
    if (!empty($spo)){
91
        // This is a setPriortiyOnly Request.
92
 
93
    }else
94
    {
95
        // if we are to start a torrent then do so
96
 
97
        // check to see if the path to the python script is valid
98
        if (!is_file($cfg["btphpbin"]))
99
        {
100
            AuditAction($cfg["constants"]["error"], "Error  Path for ".$cfg["btphpbin"]." is not valid");
101
            if (IsAdmin())
102
            {
103
                header("location: admin.php?op=configSettings");
104
                exit();
105
            }
106
            else
107
            {
108
                $messages .= "<b>Error</b> TorrentFlux settings are not correct (path to python script is not valid) -- please contact an admin.<br>";
109
            }
110
        }
111
 
112
        $command = "";
113
 
114
        $rate = getRequestVar('rate');
115
        if (empty($rate))
116
        {
117
            if ($rate != 0)
118
            {
119
                $rate = $cfg["max_upload_rate"];
120
            }
121
        }
122
        $drate = getRequestVar('drate');
123
        if (empty($drate))
124
        {
125
            if ($drate != 0)
126
            {
127
                $drate = $cfg["max_download_rate"];
128
            }
129
        }
130
        $superseeder = getRequestVar('superseeder');
131
        if (empty($superseeder))
132
        {
133
            $superseeder = "0"; // should be 0 in most cases
134
        }
135
        $runtime = getRequestVar('runtime');
136
        if (empty($runtime))
137
        {
138
            $runtime = $cfg["torrent_dies_when_done"];
139
        }
140
 
141
        $maxuploads = getRequestVar('maxuploads');
142
        if (empty($maxuploads))
143
        {
144
            if ($maxuploads != 0)
145
            {
146
                $maxuploads = $cfg["max_uploads"];
147
            }
148
        }
149
        $minport = getRequestVar('minport');
150
        if (empty($minport))
151
        {
152
            $minport = $cfg["minport"];
153
        }
154
        $maxport = getRequestVar('maxport');
155
        if (empty($maxport))
156
        {
157
            $maxport = $cfg["maxport"];
158
        }
159
        $rerequest = getRequestVar("rerequest");
160
        if (empty($rerequest))
161
        {
162
            $rerequest = $cfg["rerequest_interval"];
163
        }
164
        $sharekill = getRequestVar('sharekill');
165
 
166
        if ($runtime == "True" )
167
            $sharekill = "-1";
168
 
169
        if (empty($sharekill))
170
        {
171
            if ($sharekill != "0")
172
            {
173
                $sharekill = $cfg["sharekill"];
174
            }
175
        }
176
        if ($cfg["AllowQueing"])
177
        {
178
            if(IsAdmin())
179
            {
180
                $queue = getRequestVar('queue');
181
                if($queue == 'on')
182
                {
183
                    $queue = "1";
184
                }else
185
                {
186
                    $queue = "0";
187
                }
188
            }
189
            else
190
            {
191
                $queue = "1";
192
            }
193
        }
194
 
195
        $torrent = urldecode($torrent);
196
        $alias = getAliasName($torrent);
197
        $owner = getOwner($torrent);
198
 
199
        // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
200
        // This is to help manage user downloads by their user names
201
        //if the user's path doesnt exist, create it
202
        if (!is_dir($cfg["path"]."/".$owner))
203
        {
204
            if (is_writable($cfg["path"]))
205
            {
206
                mkdir($cfg["path"]."/".$owner, 0777);
207
            }
208
            else
209
            {
210
                AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable.");
211
                if (IsAdmin())
212
                {
213
                    header("location: admin.php?op=configSettings");
214
                    exit();
215
                }
216
                else
217
                {
218
                    $messages .= "<b>Error</b> TorrentFlux settings are not correct (path is not writable) -- please contact an admin.<br>";
219
                }
220
            }
221
        }
222
 
223
        // create AliasFile object and write out the stat file
224
        $af = new AliasFile($cfg["torrent_file_path"].$alias.".stat", $owner);
225
 
226
        if ($cfg["AllowQueing"])
227
        {
228
            if($queue == "1")
229
            {
230
                $af->QueueTorrentFile();  // this only writes out the stat file (does not start torrent)
231
            }
232
            else
233
            {
234
                $af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
235
            }
236
        }
237
        else
238
        {
239
            $af->StartTorrentFile();  // this only writes out the stat file (does not start torrent)
240
        }
241
 
242
        if (usingTornado())
243
        {
244
            $command = $runtime." ".$sharekill." ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile '".$cfg["torrent_file_path"].$torrent."' --display_interval 5 --max_download_rate ". $drate ." --max_upload_rate ".$rate." --max_uploads ".$maxuploads." --minport ".$minport." --maxport ".$maxport." --rerequest_interval ".$rerequest." --super_seeder ".$superseeder;
245
 
246
            if(file_exists($cfg["torrent_file_path"].$alias.".prio")) {
247
                $priolist = explode(',',file_get_contents($cfg["torrent_file_path"].$alias.".prio"));
248
                $priolist = implode(',',array_slice($priolist,1,$priolist[0]));
249
                $command .= " --priority ".$priolist;
250
            }
251
 
252
            $command .= " ".$cfg["cmd_options"]." > /dev/null &";
253
 
254
            if ($cfg["AllowQueing"] && $queue == "1")
255
            {
256
                //  This file is being queued.
257
            }
258
            else
259
            {
260
                // This flie is being started manually.
261
 
262
                if (! array_key_exists("pythonCmd", $cfg))
263
                {
264
                    insertSetting("pythonCmd","/usr/bin/python");
265
                }
266
 
267
                if (! array_key_exists("debugTorrents", $cfg))
268
                {
269
                    insertSetting("debugTorrents", "0");
270
                }
271
 
272
                if (!$cfg["debugTorrents"])
273
                {
274
                    $pyCmd = $cfg["pythonCmd"] . " -OO";
275
                }else{
276
                    $pyCmd = $cfg["pythonCmd"];
277
                }
278
 
279
                $command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .$cfg["btphpbin"] . " " . $command;
280
            }
281
 
282
        }
283
        else
284
        {
285
            // Must be using the Original BitTorrent Client
286
            // This is now being required to allow Queing functionality
287
            //$command = "cd " . $cfg["path"] . $owner . "; nohup " . $cfg["btphpbin"] . " ".$runtime." ".$sharekill." ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile \"".$cfg["torrent_file_path"].$torrent."\" --display_interval 5 --max_download_rate ". $drate ." --max_upload_rate ".$rate." --max_uploads ".$maxuploads." --minport ".$minport." --maxport ".$maxport." --rerequest_interval ".$rerequest." ".$cfg["cmd_options"]." > /dev/null &";
288
            $messages .= "<b>Error</b> BitTornado is only supported Client at this time.<br>";
289
        }
290
 
291
        // write the session to close so older version of PHP will not hang
292
        session_write_close("TorrentFlux");
293
 
294
        if($af->running == "3")
295
        {
296
            writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command);
297
            AuditAction($cfg["constants"]["queued_torrent"], $torrent."<br>Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest);
298
            AuditAction($cfg["constants"]["queued_torrent"], $command);
299
        }
300
        else
301
        {
302
            // The following command starts the torrent running! w00t!
303
            $result = exec($command);
304
 
305
            AuditAction($cfg["constants"]["start_torrent"], $torrent."<br>Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest);
306
 
307
            // slow down and wait for thread to kick off.
308
            // otherwise on fast servers it will kill stop it before it gets a chance to run.
309
            sleep(1);
310
        }
311
 
312
        if ($messages == "")
313
        {
314
            if (array_key_exists("closeme",$_POST))
315
            {
316
?>
317
                <script  language="JavaScript">
318
                    window.opener.location.reload(true);
319
                    window.close();
320
                </script>
321
<?php
322
               exit();
323
            }
324
            else
325
            {
326
                header("location: index.php");
327
                exit();
328
            }
329
        }
330
        else
331
        {
332
            AuditAction($cfg["constants"]["error"], $messages);
333
        }
334
    }
335
}
336
 
337
 
338
// Do they want us to get a torrent via a URL?
339
$url_upload = getRequestVar('url_upload');
340
 
341
if(! $url_upload == '')
342
{
343
    $arURL = explode("/", $url_upload);
344
    $file_name = urldecode($arURL[count($arURL)-1]); // get the file name
345
    $file_name = str_replace(array("'",","), "", $file_name);
346
    $file_name = stripslashes($file_name);
347
    $ext_msg = "";
348
 
349
    // Check to see if url has something like ?passkey=12345
350
    // If so remove it.
351
    if( ( $point = strrpos( $file_name, "?" ) ) !== false )
352
    {
353
        $file_name = substr( $file_name, 0, $point );
354
    }
355
 
356
    $ret = strrpos($file_name,".");
357
    if ($ret === false)
358
    {
359
        $file_name .= ".torrent";
360
    }
361
    else
362
    {
363
        if(!strcmp(strtolower(substr($file_name, strlen($file_name)-8, 8)), ".torrent") == 0)
364
        {
365
            $file_name .= ".torrent";
366
        }
367
    }
368
 
369
    $url_upload = str_replace(" ", "%20", $url_upload);
370
 
371
    // This is to support Sites that pass an id along with the url for torrent downloads.
372
    $tmpId = getRequestVar("id");
373
    if(!empty($tmpId))
374
    {
375
        $url_upload .= "&id=".$tmpId;
376
    }
377
 
378
    // Call fetchtorrent to retrieve the torrent file
379
    $output = FetchTorrent( $url_upload );
380
 
381
    if (array_key_exists("save_torrent_name",$cfg))
382
    {
383
        if ($cfg["save_torrent_name"] != "")
384
        {
385
            $file_name = $cfg["save_torrent_name"];
386
        }
387
    }
388
 
389
    $file_name = cleanFileName($file_name);
390
 
391
    // if the output had data then write it to a file
392
    if ((strlen($output) > 0) && (strpos($output, "<br />") === false))
393
    {
394
        if (is_file($cfg["torrent_file_path"].$file_name))
395
        {
396
            // Error
397
            $messages .= "<b>Error</b> with (<b>".$file_name."</b>), the file already exists on the server.<br><center><a href=\"".$_SERVER['PHP_SELF']."\">[Refresh]</a></center>";
398
            $ext_msg = "DUPLICATE :: ";
399
        }
400
        else
401
        {
402
            // open a file to write to
403
            $fw = fopen($cfg["torrent_file_path"].$file_name,'w');
404
            fwrite($fw, $output);
405
            fclose($fw);
406
        }
407
    }
408
    else
409
    {
410
        $messages .= "<b>Error</b> Getting the File (<b>".$file_name."</b>), Could be a Dead URL.<br><center><a href=\"".$_SERVER['PHP_SELF']."\">[Refresh]</a></center>";
411
    }
412
 
413
    if ($messages == "")
414
    {
415
        AuditAction($cfg["constants"]["url_upload"], $file_name);
416
        header("location: index.php");
417
        exit();
418
    }
419
    else
420
    {
421
        // there was an error
422
        AuditAction($cfg["constants"]["error"], $cfg["constants"]["url_upload"]." :: ".$ext_msg.$file_name);
423
    }
424
}
425
 
426
// Handle the file upload if there is one
427
if(!empty($_FILES['upload_file']['name']))
428
{
429
    $file_name = stripslashes($_FILES['upload_file']['name']);
430
    $file_name = str_replace(array("'",","), "", $file_name);
431
    $file_name = cleanFileName($file_name);
432
    $ext_msg = "";
433
 
434
    if($_FILES['upload_file']['size'] <= 1000000 &&
435
       $_FILES['upload_file']['size'] > 0)
436
    {
437
        if (ereg(getFileFilter($cfg["file_types_array"]), $file_name))
438
        {
439
            //FILE IS BEING UPLOADED
440
            if (is_file($cfg["torrent_file_path"].$file_name))
441
            {
442
                // Error
443
                $messages .= "<b>Error</b> with (<b>".$file_name."</b>), the file already exists on the server.<br><center><a href=\"".$_SERVER['PHP_SELF']."\">[Refresh]</a></center>";
444
                $ext_msg = "DUPLICATE :: ";
445
            }
446
            else
447
            {
448
                if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $cfg["torrent_file_path"].$file_name))
449
                {
450
                    chmod($cfg["torrent_file_path"].$file_name, 0644);
451
 
452
                    AuditAction($cfg["constants"]["file_upload"], $file_name);
453
 
454
                    header("location: index.php");
455
                }
456
                else
457
                {
458
                    $messages .= "<font color=\"#ff0000\" size=3>ERROR: File not uploaded, file could not be found or could not be moved:<br>".$cfg["torrent_file_path"] . $file_name."</font><br>";
459
                }
460
            }
461
        }
462
        else
463
        {
464
            $messages .= "<font color=\"#ff0000\" size=3>ERROR: The type of file you are uploading is not allowed.</font><br>";
465
        }
466
    }
467
    else
468
    {
469
        $messages .= "<font color=\"#ff0000\" size=3>ERROR: File not uploaded, check file size limit.</font><br>";
470
    }
471
 
472
    if($messages != "")
473
    {
474
        // there was an error
475
        AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"]." :: ".$ext_msg.$file_name);
476
    }
477
}  // End File Upload
478
 
479
 
480
// if a file was set to be deleted then delete it
481
$delfile = getRequestVar('delfile');
482
if(! $delfile == '')
483
{
484
    $alias_file = getRequestVar('alias_file');
485
    if (($cfg["user"] == getOwner($delfile)) || IsAdmin())
486
    {
487
        @unlink($cfg["torrent_file_path"].$delfile);
488
        @unlink($cfg["torrent_file_path"].$alias_file);
489
        // try to remove the QInfo if in case it was queued.
490
        @unlink($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo");
491
 
492
        // try to remove the pid file
493
        @unlink($cfg["torrent_file_path"].$alias_file.".pid");
494
        @unlink($cfg["torrent_file_path"].getAliasName($delfile).".prio");
495
 
496
        AuditAction($cfg["constants"]["delete_torrent"], $delfile);
497
 
498
        header("location: index.php");
499
        exit();
500
    }
501
    else
502
    {
503
        AuditAction($cfg["constants"]["error"], $cfg["user"]." attempted to delete ".$delfile);
504
    }
505
}
506
 
507
// Did the user select the option to kill a running torrent?
508
$kill = getRequestVar('kill');
509
if(! $kill == '')
510
{
511
    include_once("AliasFile.php");
512
    include_once("RunningTorrent.php");
513
 
514
    $kill_torrent = getRequestVar('kill_torrent');
515
    $alias_file = getRequestVar('alias_file');
516
    // We are going to write a '0' on the front of the stat file so that
517
    // the BT client will no to stop -- this will report stats when it dies
518
    $the_user = getOwner($kill_torrent);
519
    // read the alias file
520
    // create AliasFile object
521
    $af = new AliasFile($cfg["torrent_file_path"].$alias_file, $the_user);
522
    if($af->percent_done < 100)
523
    {
524
        // The torrent is being stopped but is not completed dowloading
525
        $af->percent_done = ($af->percent_done + 100)*-1;
526
        $af->running = "0";
527
        $af->time_left = "Torrent Stopped";
528
    }
529
    else
530
    {
531
        // Torrent was seeding and is now being stopped
532
        $af->percent_done = 100;
533
        $af->running = "0";
534
        $af->time_left = "Download Succeeded!";
535
    }
536
 
537
    // see if the torrent process is hung.
538
    if (!is_file($cfg["torrent_file_path"].$alias_file.".pid"))
539
    {
540
        $runningTorrents = getRunningTorrents();
541
        foreach ($runningTorrents as $key => $value)
542
        {
543
            $rt = new RunningTorrent($value);
544
            if ($rt->statFile == $alias_file) {
545
                AuditAction($cfg["constants"]["error"], "Posible Hung Process " . $rt->processId);
546
            //    $result = exec("kill ".$rt->processId);
547
            }
548
        }
549
    }
550
 
551
    // Write out the new Stat File
552
    $af->WriteFile();
553
 
554
    AuditAction($cfg["constants"]["kill_torrent"], $kill_torrent);
555
    $return = getRequestVar('return');
556
    if (!empty($return))
557
    {
558
        sleep(3);
559
        $result = exec("kill ".$kill);
560
        // try to remove the pid file
561
        @unlink($cfg["torrent_file_path"].$alias_file.".pid");
562
        header("location: ".$return.".php?op=queueSettings");
563
        exit();
564
    }
565
    else
566
    {
567
        header("location: index.php");
568
        exit();
569
    }
570
}
571
 
572
// Did the user select the option to remove a torrent from the Queue?
573
if(isset($_REQUEST["dQueue"]))
574
{
575
    $alias_file = getRequestVar('alias_file');
576
    $QEntry = getRequestVar('QEntry');
577
 
578
    // Is the Qinfo file still there?
579
    if (file_exists($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo"))
580
    {
581
        // Yes, then delete it and update the stat file.
582
        include_once("AliasFile.php");
583
        // We are going to write a '2' on the front of the stat file so that
584
        // it will be set back to New Status
585
        $the_user = getOwner($QEntry);
586
        // read the alias file
587
        // create AliasFile object
588
        $af = new AliasFile($cfg["torrent_file_path"].$alias_file, $the_user);
589
 
590
        if($af->percent_done > 0 && $af->percent_done < 100)
591
        {
592
            // has downloaded something at some point, mark it is incomplete
593
            $af->running = "0";
594
            $af->time_left = "Torrent Stopped";
595
        }
596
 
597
        if ($af->percent_done == 0 || $af->percent_done == "")
598
        {
599
            $af->running = "2";
600
            $af->time_left = "";
601
        }
602
 
603
        if ($af->percent_done == 100)
604
        {
605
            // Torrent was seeding and is now being stopped
606
            $af->running = "0";
607
            $af->time_left = "Download Succeeded!";
608
        }
609
 
610
        // Write out the new Stat File
611
        $af->WriteFile();
612
 
613
        // Remove Qinfo file.
614
        @unlink($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo");
615
 
616
        AuditAction($cfg["constants"]["unqueued_torrent"], $QEntry);
617
    }
618
    else
619
    {
620
        // torrent has been started... try and kill it.
621
        AuditAction($cfg["constants"]["unqueued_torrent"], $QEntry . "has been started -- TRY TO KILL IT");
622
        header("location: index.php?alias_file=".$alias_file."&kill=true&kill_torrent=".urlencode($QEntry));
623
        exit();
624
    }
625
 
626
    header("location: index.php");
627
    exit();
628
}
629
 
630
$drivespace = getDriveSpace($cfg["path"]);
631
 
632
 
633
/************************************************************
634
 
635
************************************************************/
636
?>
637
<html>
638
<head>
639
    <title><?php echo $cfg["pagetitle"] ?></title>
640
    <link rel="icon" href="images/favicon.ico" type="image/x-icon" />
641
    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
642
    <LINK REL="StyleSheet" HREF="themes/<?php echo $cfg["theme"] ?>/style.css" TYPE="text/css">
643
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache; charset=<?php echo _CHARSET ?>">
644
<?php
645
    if(!isset($_SESSION['prefresh']) || ($_SESSION['prefresh'] == true))
646
    {
647
        echo "<meta http-equiv=\"REFRESH\" content=\"".$cfg["page_refresh"].";URL=index.php\">";
648
    }
649
?>
650
<div id="overDiv" style="position:absolute;visibility:hidden;z-index:1000;"></div>
651
<script language="JavaScript">
652
    var ol_closeclick = "1";
653
    var ol_close = "<font color=#ffffff><b>X</b></font>";
654
    var ol_fgclass = "fg";
655
    var ol_bgclass = "bg";
656
    var ol_captionfontclass = "overCaption";
657
    var ol_closefontclass = "overClose";
658
    var ol_textfontclass = "overBody";
659
    var ol_cap = "&nbsp;Torrent Status";
660
</script>
661
<script src="overlib.js" type="text/javascript"></script>
662
<script language="JavaScript">
663
function ShowDetails(name_file)
664
{
665
  window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=430,height=225')
666
}
667
function StartTorrent(name_file)
668
{
669
    myWindow = window.open (name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=530')
670
}
671
function ConfirmDelete(file)
672
{
673
    return confirm("<?php echo _ABOUTTODELETE ?>: " + file)
674
}
675
</script>
676
</head>
677
 
678
<body topmargin="8" bgcolor="<?php echo $cfg["main_bgcolor"] ?>">
679
 
680
<div align="center">
681
 
682
<?php
683
if ($messages != "")
684
{
685
?>
686
<table border="1" cellpadding="10" bgcolor="#ff9b9b">
687
<tr>
688
    <td><div align="center"><?php echo $messages ?></div></td>
689
</tr>
690
</table><br><br>
691
<?php
692
}
693
?>
694
<table border="0" cellpadding="0" cellspacing="0" width="760">
695
<tr>
696
    <td>
697
<table border="1" bordercolor="<?php echo $cfg["table_border_dk"] ?>" cellpadding="4" cellspacing="0" width="100%">
698
<tr>
699
    <td colspan="2" background="themes/<?php echo $cfg["theme"] ?>/images/bar.gif">
700
    <?php DisplayTitleBar($cfg["pagetitle"]); ?>
701
    </td>
702
</tr>
703
<tr>
704
    <td bgcolor="<?php echo $cfg["table_header_bg"] ?>">
705
    <table width="100%" cellpadding="3" cellspacing="0" border="0">
706
    <tr>
707
        <form name="form_file" action="index.php" method="post" enctype="multipart/form-data">
708
        <td>
709
        <?php echo _SELECTFILE ?>:<br>
710
        <input type="File" name="upload_file" size="40">
711
        <input type="Submit" value="<?php echo _UPLOAD ?>">
712
        </td>
713
        </form>
714
    </tr>
715
    <tr>
716
        <form name="form_url" action="index.php" method="post">
717
        <td>
718
        <hr>
719
        <?php echo _URLFILE ?>:<br>
720
        <input type="text" name="url_upload" size="50">
721
        <input type="Submit" value="<?php echo _GETFILE ?>">
722
        </td>
723
        </form>
724
    </tr>
725
<?php
726
if ($cfg["enable_search"])
727
{
728
?>
729
    <tr>
730
        <form name="form_search" action="torrentSearch.php" method="get">
731
        <td>
732
        <hr>
733
        Torrent <?php echo _SEARCH ?>:<br>
734
        <input type="text" name="searchterm" size="30" maxlength="50">
735
<?php
736
        echo buildSearchEngineDDL($cfg["searchEngine"])
737
?>
738
        <input type="Submit" value="<?php echo _SEARCH ?>">
739
        </td>
740
        </form>
741
    </tr>
742
<?php
743
}
744
?>
745
    </table>
746
 
747
    </td>
748
    <td bgcolor="<?php echo $cfg["table_data_bg"] ?>" width="310" valign="top">
749
        <table width="100%" cellpadding="1" border="0">
750
        <tr>
751
        <td valign="top">
752
        <b><?php echo _TORRENTLINKS ?>:</b><br>
753
<?php
754
        $arLinks = GetLinks();
755
        foreach($arLinks as $link)
756
        {
757
            $arURL = parse_url($link);
758
            echo "<a href=\"".$link."\" target=\"_blank\"><img src=\"images/arrow.gif\" width=9 height=9 title=\"".$link."\" border=0 align=\"baseline\">".$arURL['host']."</a><br>\n";
759
        }
760
 
761
        echo "</ul></td>";
762
 
763
        $arUsers = GetUsers();
764
        $arOnlineUsers = array();
765
        $arOfflineUsers = array();
766
 
767
        for($inx = 0; $inx < count($arUsers); $inx++)
768
        {
769
            if(IsOnline($arUsers[$inx]))
770
            {
771
                array_push($arOnlineUsers, $arUsers[$inx]);
772
            }
773
            else
774
            {
775
                array_push($arOfflineUsers, $arUsers[$inx]);
776
            }
777
        }
778
 
779
        echo "<td bgcolor=\"".$cfg["table_data_bg"]."\" valign=\"top\">";
780
        echo "<b>"._ONLINE.":</b><br>";
781
 
782
        for($inx = 0; $inx < count($arOnlineUsers); $inx++)
783
        {
784
            echo "<a href=\"message.php?to_user=".$arOnlineUsers[$inx]."\">";
785
            echo "<img src=\"images/user.gif\" width=17 height=14 title=\"\" border=0 align=\"bottom\">". $arOnlineUsers[$inx];
786
            echo "</a><br>\n";
787
        }
788
 
789
        // Does the user want to see offline users?
790
        if ($cfg["hide_offline"] == false)
791
        {
792
            echo "<b>"._OFFLINE.":</b></br>";
793
            // Show offline users
794
 
795
            for($inx = 0; $inx < count($arOfflineUsers); $inx++)
796
            {
797
                echo "<a href=\"message.php?to_user=".$arOfflineUsers[$inx]."\">";
798
                echo "<img src=\"images/user_offline.gif\" width=17 height=14 title=\"\" border=0 align=\"bottom\">".$arOfflineUsers[$inx];
799
                echo "</a><br>\n";
800
            }
801
        }
802
 
803
        echo "</td>";
804
?>
805
        </tr>
806
        </table>
807
    </td>
808
</tr>
809
<tr>
810
    <td bgcolor="<?php echo $cfg["table_header_bg"] ?>" colspan="2">
811
<?php
812
    displayDriveSpaceBar($drivespace);
813
?>
814
    </td>
815
</tr>
816
<tr>
817
    <td bgcolor="<?php echo $cfg["table_data_bg"] ?>" colspan="2">
818
    <div align="center">
819
    <font face="Arial" size="2">
820
    <a href="readrss.php">
821
    <img src="images/download_owner.gif" width="16" height="16" border="0" title="RSS Torrents" align="absmiddle">RSS Torrents</a>
822
     |
823
    <a href="drivespace.php">
824
    <img src="images/hdd.gif" width="16" height="16" border="0" title="<?php echo $drivespace ?>% Used" align="absmiddle"><?php echo _DRIVESPACE ?></a>
825
     |
826
    <a href="who.php">
827
    <img src="images/who.gif" width="16" height="16" title="" border="0" align="absmiddle"><?php echo _SERVERSTATS ?></a>
828
     |
829
    <a href="all_services.php">
830
    <img src="images/all.gif" width="16" height="16" title="" border="0" align="absmiddle"><?php echo _ALL ?></a>
831
     |
832
    <a href="dir.php">
833
    <img src="images/folder.gif" width="16" height="16" title="" border="0" align="absmiddle"><?php echo _DIRECTORYLIST ?></a>
834
     |
835
    <a href="dir.php?dir=<?php echo $cfg["user"] ?>"><img src="images/folder.gif" width="16" height="16" title="My Directory" border="0" align="absmiddle">My Directory</a>
836
    </font>
837
    </div>
838
    </td>
839
</tr>
840
</table>
841
<?php
842
    getDirList($cfg["torrent_file_path"]);
843
?>
844
<tr><td bgcolor="<?php echo $cfg["table_header_bg"] ?>" colspan="6">
845
 
846
<table width="100%" border="0" cellpadding="0" cellspacing="0">
847
<tr>
848
    <td valign="top">
849
 
850
    <div align="center">
851
 
852
    <table>
853
    <tr>
854
        <td><img src="images/properties.png" width="18" height="13" title="<?php echo _TORRENTDETAILS ?>"></td>
855
        <td class="tiny"><?php echo _TORRENTDETAILS ?>&nbsp;&nbsp;&nbsp;</td>
856
        <td><img src="images/run_on.gif" width="16" height="16" title="<?php echo _RUNTORRENT ?>"></td>
857
        <td class="tiny"><?php echo _RUNTORRENT ?>&nbsp;&nbsp;&nbsp;</td>
858
        <td><img src="images/kill.gif" width="16" height="16" title="<?php echo _STOPDOWNLOAD ?>"></td>
859
        <td class="tiny"><?php echo _STOPDOWNLOAD ?>&nbsp;&nbsp;&nbsp;</td>
860
        <?php
861
        if ($cfg["AllowQueing"])
862
        {
863
        ?>
864
        <td><img src="images/queued.gif" width="16" height="16" title="<?php echo _DELQUEUE ?>"></td>
865
        <td class="tiny"><?php echo _DELQUEUE ?>&nbsp;&nbsp;&nbsp;</td>
866
        <?php
867
        }
868
        ?>
869
        <td><img src="images/seed_on.gif" width="16" height="16" title="<?php echo _SEEDTORRENT ?>"></td>
870
        <td class="tiny"><?php echo _SEEDTORRENT ?>&nbsp;&nbsp;&nbsp;</td>
871
        <td><img src="images/delete_on.gif" width="16" height="16" title="<?php echo _DELETE ?>"></td>
872
        <td class="tiny"><?php echo _DELETE ?></td>
873
        <?php
874
        if ($cfg["enable_torrent_download"])
875
        {
876
        ?>
877
        <td>&nbsp;&nbsp;&nbsp;<img src="images/down.gif" width="9" height="9" title="<?php echo _DELQUEUE ?>"></td>
878
        <td class="tiny">Download Torrent</td>
879
        <?php
880
        }
881
        ?>
882
    </tr>
883
    </table>
884
 
885
 
886
    <table width="100%" cellpadding="5">
887
    <tr>
888
        <td width="33%">
889
            <div class="tiny">
890
<?php
891
    if(checkQManager() > 0)
892
    {
893
         echo "<img src=\"images/green.gif\" align=\"absmiddle\" title=\"Queue Manager Running\" align=\"absmiddle\"> Queue Manager Running<br>";
894
         echo "<strong>".strval(getRunningTorrentCount())."</strong> torrent(s) running and <strong>".strval(getNumberOfQueuedTorrents())."</strong> queued.<br>";
895
         echo "Total torrents server will run: <strong>".$cfg["maxServerThreads"]."</strong><br>";
896
         echo "Total torrents a user may run: <strong>".$cfg["maxUserThreads"]."</strong><br>";
897
         echo "* Torrents are queued when limits are met.<br>";
898
    }
899
    else
900
    {
901
        echo "<img src=\"images/black.gif\" title=\"Queue Manager Off\" align=\"absmiddle\"> Queue Manager Off<br><br>";
902
    }
903
?>
904
            </div>
905
        </td>
906
        <td width="33%" valign="bottom">
907
            <div align="center" class="tiny">
908
<?php
909
 
910
    if(!isset($_SESSION['prefresh']) || ($_SESSION['prefresh'] == true))
911
    {
912
        echo "*** "._PAGEWILLREFRESH." ".$cfg["page_refresh"]." "._SECONDS." ***<br>";
913
        echo "<a href=\"".$_SERVER['PHP_SELF']."?pagerefresh=false\"><font class=\"tiny\">"._TURNOFFREFRESH."</font></a>";
914
    }
915
    else
916
    {
917
        echo "<a href=\"".$_SERVER['PHP_SELF']."?pagerefresh=true\"><font class=\"tiny\">"._TURNONREFRESH."</font></a>";
918
    }
919
 
920
 
921
    if($drivespace >= 98)
922
    {
923
 
924
        echo "\n\n<script  language=\"JavaScript\">\n alert(\""._WARNING.": ".$drivespace."% "._DRIVESPACEUSED."\")\n </script>";
925
    }
926
 
927
    if (!array_key_exists("total_download",$cfg)) $cfg["total_download"] = 0;
928
    if (!array_key_exists("total_upload",$cfg)) $cfg["total_upload"] = 0;
929
 
930
 
931
?>
932
            </div>
933
        </td>
934
        <td valign="top" width="33%" align="right">
935
 
936
            <table>
937
            <tr>
938
                <td class="tiny" align="right"><?php echo _CURRENTDOWNLOAD ?>:</td>
939
                <td class="tiny"><strong><?php echo number_format($cfg["total_download"], 2); ?></strong> kB/s</td>
940
            </tr>
941
            <tr>
942
                <td class="tiny" align="right"><?php echo _CURRENTUPLOAD ?>:</td>
943
                <td class="tiny"><strong><?php echo number_format($cfg["total_upload"], 2); ?></strong> kB/s</td>
944
            </tr>
945
            <tr>
946
                <td class="tiny" align="right"><?php echo _FREESPACE ?>:</td>
947
                <td class="tiny"><strong><?php echo formatFreeSpace($cfg["free_space"]) ?></strong></td>
948
            </tr>
949
            <tr>
950
                <td class="tiny" align="right"><?php echo _SERVERLOAD ?>:</td>
951
                <td class="tiny">
952
        <?php
953
            if ($cfg["show_server_load"] && isFile($cfg["loadavg_path"]))
954
            {
955
                $loadavg_array = explode(" ", exec("cat ".$cfg["loadavg_path"]));
956
                $loadavg = $loadavg_array[2];
957
                echo "<strong>".$loadavg."</strong>";
958
            }
959
            else
960
            {
961
                echo "<strong>n/a</strong>";
962
            }
963
        ?>
964
                </td>
965
            </tr>
966
            </table>
967
 
968
        </td>
969
    </tr>
970
    </table>
971
 
972
 
973
 
974
 
975
 
976
    </div>
977
 
978
    </td>
979
</tr>
980
</table>
981
 
982
 
983
 
984
</td></tr>
985
</table>
986
 
987
<?php
988
    echo DisplayTorrentFluxLink();
989
    // At this point Any User actions should have taken place
990
    // Check to see if the user has a force_read message from an admin
991
    if (IsForceReadMsg())
992
    {
993
        // Yes, then warn them
994
?>
995
        <script  language="JavaScript">
996
        if (confirm("<?php echo _ADMINMESSAGE ?>"))
997
        {
998
            document.location = "readmsg.php";
999
        }
1000
        </script>
1001
<?php
1002
    }
1003
?>
1004
 
1005
    </td>
1006
</tr>
1007
</table>
1008
</body>
1009
</html>