\n"; if (!isset($RpcApi)) { echo "NZBGetWeb: Could not find required extension or library. Consult README-file for installation instructions."; Exit(-1); } if (count($_GET) > 0) { Redirect($LoginRedirectPage); } $wantstart = false; $connected = false; $phpvars = null; if (isset($_COOKIE['c_start']) && $ServerStartCommand != '') { SetCookie("c_start", "", time() - 10000); // delete cookie $wantstart = true; } if (!$wantstart) { $phpvars = GetInfo($groupmode); $connected = !IsConnectError($phpvars); } function add_category_combo($category, $id, $paused) { global $Categories, $MiniJavaScript; if ($category == '' && count($Categories) == 0) { return; } $catfound = false; if ($MiniJavaScript) { echo ' "; } else { echo '
'; echo ''; echo ''; echo ""; echo ''; echo ' "; echo ''; echo ''; echo '
'; } } function currently_downloading ($phpvars) { echo '
'; if (isset($phpvars['activegroup'])) { //Download in progress, display info $cur_queued=$phpvars['activegroup']; if (!$phpvars['status']['ServerPaused']) echo '
Currently downloading

'; else echo '
Currently downloading (pausing)

'; echo ''; echo ''; echo ''; echo ''; $grouppaused=($cur_queued['PausedSizeLo'] != 0) && ($cur_queued['RemainingSizeLo']==$cur_queued['PausedSizeLo']); echo ($grouppaused ? '' : ''); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ($grouppaused ? '' : ''); echo ''; echo ''; echo ''; echo ''; echo ''; echo '
namecategory
  speed      left    remaining time
remove nzbmove nzb to top in queuemove nzb upmove nzb downmove nzb to bottom in queuepause nzbresume nzb'; add_category_combo($cur_queued['Category'], $cur_queued['LastID'], $grouppaused); echo '
'.namereplace($cur_queued['NZBNicename']).'
'; echo ''; echo ""; echo ""; echo "'; echo '
".round0($phpvars['status']['DownloadRate']/1024)." KB/s  ".formatSizeMB($cur_queued['RemainingSizeMB']-$cur_queued['PausedSizeMB'])."  "; if ($phpvars['status']['DownloadRate'] > 0) echo sec2hms(($cur_queued['RemainingSizeMB']-$cur_queued['PausedSizeMB'])/($phpvars['status']['DownloadRate']/1024/1024)); echo '
'; echo '
'; echo ''; echo ''; echo ''; echo "'; echo '
'; $a=$cur_queued['FileSizeMB']-$cur_queued['PausedSizeMB']; if ($a > 0) $percent_complete=round0(($a-($cur_queued['RemainingSizeMB']-$cur_queued['PausedSizeMB']))*100/$a); else $percent_complete=100; echo ""; echo '$percent_complete%"; echo '
'; echo '
'; } else { if ($phpvars['status']['ServerPaused']) { echo '
Server is paused

'; echo '
resume
'; } else echo '
Server is sleeping

'; } echo '

'; } function queued_downloading($phpvars, $page) { if (count($phpvars['queuedgroups']) == 0) return; global $GroupsPerPage; $cnt = count($phpvars['queuedgroups']); $pagecount = pagecount($cnt, $GroupsPerPage); if ($page > $pagecount) $page = $pagecount; if ($page < 1) $page = 1; echo '
'; echo '
Queued

'; echo ''; echo ''; echo ''; foreach (array_slice($phpvars['queuedgroups'], ($page - 1) * $GroupsPerPage, $GroupsPerPage) as $cur_queued) { echo ''; $grouppaused=($cur_queued['PausedSizeLo'] != 0) && ($cur_queued['RemainingSizeLo']==$cur_queued['PausedSizeLo']); echo ($grouppaused ? '' : ''); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ($grouppaused ? '' : ''); echo ''; echo ''; } echo '
namecategory
  total      left    estimated time
remove nzbmove nzb to top in queuemove nzb upmove nzb downmove nzb to bottom in queuepause nzbresume nzb'; add_category_combo($cur_queued['Category'], $cur_queued['LastID'], $grouppaused); echo '
'.namereplace($cur_queued['NZBNicename']).'
'; echo ''; echo ""; echo ""; echo "'; echo '
".formatSizeMB($cur_queued['FileSizeMB'])."  ".formatSizeMB($cur_queued['RemainingSizeMB']-$cur_queued['PausedSizeMB'])."  "; if ($phpvars['status']['DownloadRate'] > 0) echo sec2hms(($cur_queued['RemainingSizeMB']-$cur_queued['PausedSizeMB'])/($phpvars['status']['DownloadRate']/1024/1024)); echo '
'; echo '
'; if ($cnt > $GroupsPerPage) { pagelist($cnt, $page, $GroupsPerPage, 'page'); } echo '

'; } function has_other_postfiles_from_same_nzb($phpvars, $proc){ foreach ($phpvars['postqueue'] as $cur_proc) { if (($cur_proc['InfoName'] != $proc['InfoName']) && ($cur_proc['NZBFilename'] == $proc['NZBFilename'])) return true; } return false; } function currently_processing($phpvars, $page){ if (count($phpvars['postqueue']) == 0) return; $cur_proc=$phpvars['postqueue'][0]; $disptime=""; $completed = ""; $remtime=true; if ($cur_proc['Stage'] == 'LOADING_PARS') { $stage="loading par-files"; } else if ($cur_proc['Stage'] == 'VERIFYING_SOURCES') { $stage="verifying files"; } else if ($cur_proc['Stage'] == 'REPAIRING') { $stage="repairing files"; } else if ($cur_proc['Stage'] == 'VERIFYING_REPAIRED') { $stage="verifying repaired files"; } else if ($cur_proc['Stage'] == 'EXECUTING_SCRIPT') { $stage="executing script"; $remtime=false; } else { $stage=""; } if ($remtime) { if ($cur_proc['StageTimeSec'] > 0 && $cur_proc['StageProgress'] > 0) { $requiredtime = $cur_proc['StageTimeSec'] * 1000 / $cur_proc['StageProgress'] - $cur_proc['StageTimeSec']; $disptime = sec2hms($requiredtime); } } else { $disptime=sec2hms($cur_proc['StageTimeSec']); } if (($cur_proc['Stage'] == 'REPAIRING') || ($cur_proc['Stage'] == 'VERIFYING_SOURCES') || ($cur_proc['Stage'] == 'VERIFYING_REPAIRED')) $completed = round1($cur_proc['StageProgress'] / 10)."%"; echo '
Currently processing

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
name
stage%'.($remtime ? "remaining time" : "elapsed time").'
'.namereplace($cur_proc[has_other_postfiles_from_same_nzb($phpvars, $cur_proc) ? 'InfoName' : 'NZBNicename']).'
'.$stage.''.$completed.''.$disptime.'
'; if (($cur_proc['Stage'] == 'LOADING_PARS') || ($cur_proc['Stage'] == 'VERIFYING_SOURCES') || ($cur_proc['Stage'] == 'VERIFYING_REPAIRED')) { echo ''; echo ''; echo ''; echo ''; echo '
'.($cur_proc['ProgressLabel']).' ('.(round1($cur_proc['FileProgress'] / 10)).'%)
'; } // Messages global $NewMessagesFirst, $PostMessagesPerPage, $MiniLogColumns; $a=$cur_proc['Log']; if ($PostMessagesPerPage > 0 && isset($a) && count($a) > 0) { if ($NewMessagesFirst) $a=array_reverse($a); $cnt = count($a); $pagecount = pagecount($cnt, $PostMessagesPerPage); if ($page > $pagecount) $page = $pagecount; if ($page < 1) $page = 1; $per_page = $PostMessagesPerPage; if ($NewMessagesFirst) { $start = ($page - 1) * $PostMessagesPerPage; } else { $start = $cnt - $page * $PostMessagesPerPage; if ($start < 0) { $per_page = $PostMessagesPerPage + $start; $start = 0; } } echo '
Script-output
'; echo ''; foreach (array_slice($a, $start, $per_page) as $info) { if ($MiniLogColumns) { echo ''; } else { echo ''; } } echo '
'.$info['Kind'].''.FormatLogText($info['Text']).'
'.$info['Kind'].' '.FormatLogText($info['Text']).'
'; if ($cnt > $PostMessagesPerPage) { pagelist($cnt, $page, $PostMessagesPerPage, 'postlogpage'); } echo '
'; } echo '

'; } function queued_processing($phpvars){ $queue=array_slice($phpvars['postqueue'], 1); if (count($queue) == 0) return; echo '
Queued

'; echo ''; //echo ''; foreach ($queue as $cur_proc) { echo ""; echo "'; echo ''; } echo '
name
".namereplace($cur_proc[has_other_postfiles_from_same_nzb($phpvars, $cur_proc) ? 'InfoName' : 'NZBNicename']).'

'; } function logging ($phpvars, $page) { global $NewMessagesFirst, $MessagesPerPage, $LogTimeFormat, $MiniLogColumns; $a=$phpvars['log']; if ($NewMessagesFirst) $a=array_reverse($a); $cnt = count($a); $pagecount = pagecount($cnt, $MessagesPerPage); if ($page > $pagecount) $page = $pagecount; if ($page < 1) $page = 1; $per_page = $MessagesPerPage; if ($NewMessagesFirst) { $start = ($page - 1) * $MessagesPerPage; } else { $start = $cnt - $page * $MessagesPerPage; if ($start < 0) { $per_page = $MessagesPerPage + $start; $start = 0; } } echo '
Messages

'; echo ''; foreach (array_slice($a, $start, $per_page) as $info) { if ($MiniLogColumns) { echo ""; } else { echo "'; } } echo '
".$info['Kind']. " ". ($LogTimeFormat != '' ? "".date($LogTimeFormat, $info['Time'])."
" : "") .FormatLogText($info['Text'])."
".$info['Kind'].' '. ($LogTimeFormat != '' ? ''.date($LogTimeFormat, $info['Time']).'
' : '') .FormatLogText($info['Text']).'
'; if ($cnt > $MessagesPerPage) { pagelist($cnt, $page, $MessagesPerPage, 'logpage'); } echo '

'; } function filelist($phpvars, $page) { global $FilesPerPage; $cnt = count($phpvars['files']); $pagecount = pagecount($cnt, $FilesPerPage); if ($page > $pagecount) $page = $pagecount; if ($page < 1) $page = 1; echo '
Files for downloading

'; echo ''; echo ''; foreach (array_slice($phpvars['files'], ($page - 1) * $FilesPerPage, $FilesPerPage) as $cur_queued) { $paused=$cur_queued['Paused']; echo ''; echo ($paused ? '' : ''); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ($paused ? '' : ''); echo ''; echo ''; } echo '
nametotal
remove filemove file to top in queuemove file upmove file downmove file to bottom in queuepause fileresume file'.(round1($cur_queued['FileSizeLo'] / 1024 / 1024)).' MB
'.namereplace($cur_queued['NZBNicename']).'/'.namereplace($cur_queued['Filename']).'
'; if ($cnt > $FilesPerPage) { pagelist($cnt, $page, $FilesPerPage, 'page'); } echo '

'; } function pagecount($cnt, $per_page) { $pagecount = (int)($cnt / $per_page); if ($cnt % $per_page > 0) $pagecount++; return $pagecount; } function pagelist($cnt, $page, $per_page, $varname) { $pagecount = pagecount($cnt, $per_page); echo '

  '; for ($i = 1; $i <= $pagecount; $i++) { if ($i == $page) echo "$i  "; else echo ''.$i.'  '; } echo '

'; } function download_rate($phpvars) { echo '
'; echo '
Max download rate: '; echo ''; echo '
'; echo '

'; } function serverinfobox($phpvars) { echo '
'; echo "NZBGet version ".$phpvars['version']."
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo '
uptime:".sec2hms($phpvars['status']['UpTimeSec'])."
download time:".sec2hms($phpvars['status']['DownloadTimeSec'])."
average download rate:".round0($phpvars['status']['AverageDownloadRate']/1024)." KB/s
total downloaded:".formatSizeMB($phpvars['status']['DownloadedSizeMB'])."
free disk space:".formatSizeMB(freediskspace())."
'; echo '

'; } function servercommandbox($phpvars) { global $connected, $WebUsername, $ServerStartCommand, $ServerConfigTemplate, $ServerConfigFile, $groupmode, $MiniJavaScript; echo '
'; echo '
'; echo 'refresh'; if ($connected) { if ($phpvars['status']['ServerPaused']) { echo '   resume'; } else { echo '   pause'; } if ($ServerStartCommand != '') { echo '   shutdown'; } if ($groupmode) { echo '   files'; } else { echo '   groups'; } } else { if ($ServerStartCommand != '') { echo '   start'; } } echo '   config'; if (isset($WebUsername) && $WebUsername != '') { echo '   logout'; } echo '
'; echo '

'; } function upload_box($phpvars) { echo '
Upload NZB file
'; echo '
'; echo 'Choose a file to upload: '; echo ''; echo '
'; if (isset($_COOKIE['upload_status'])) { echo '
'; echo '
upload status
'; echo '
'.($_COOKIE['upload_status']).'
'; echo '
'; } echo '
'; } function connect_error($errormsg) { global $ServerStartCommand, $ServerConfigTemplate, $ServerConfigFile; $connectfailed = !strncmp($errormsg, "ERROR: Connect error:", 21); $connectclosed = $errormsg == "ERROR: Server closed connection"; $connectdecode = !strncmp($errormsg, "ERROR: Could not decode", 23); echo '
'; if ($connectfailed) { echo 'ERROR: NZBGetWeb could not connect to NZBGet-Server.

'; echo 'Possible reasons include:
'; echo ''; echo '
  • NZBGet-Server is not running'; if ($ServerStartCommand != '') { echo ' (start)'; } echo ';'; echo '
  • IP/Port-settings are incorrect. Check config;'; echo '
  • Firewall is not properly configured (if nzbget-server and web-interface run on different computer).'; echo ''; echo "

    Error-message reported by OS: ".substr($errormsg, 22)."
    "; } else if ($connectclosed) { echo 'ERROR: NZBGetWeb could not receive response from NZBGet-Server (although successfully connected).

    '; echo 'Possible reasons include:
    '; echo ''; echo '
  • Password incorrect. Check option "ServerPassword" in config;'; echo '
  • Server too busy, connect timeout too short. Check option "ConnectTimeout" in config;'; echo '
  • Not compatible server version.'; echo ''; } else if ($connectdecode) { echo 'ERROR: NZBGetWeb could not process response received from NZBGet-Server (although successfully connected).

    '; echo 'Possible reasons include:
    '; echo ''; echo '
  • Wrong port-settings, NZBGetWeb tries to communicate with a different kind of server (a web-server for example, but not nzbget-server). '; echo 'Check option "ServerPort" in config;'; echo '
  • Not compatible server version.'; echo ''; } else { echo ''.$errormsg.'
    '; } echo '

  • '; } function start_server() { echo '
    '; $output = array(); $retval = StartServer($output); if ($retval != 0) { echo "ERROR: Could not start server. Errorcode: $retval.

    "; if (count($output) > 0) { echo 'Output:
    '; foreach ($output as $line) { echo $line.'
    '; } } } else { echo 'INFO: Server started successfully.

    '; echo 'Please give the server few seconds for initialization, then refresh the page.
    '; } echo '

    '; } ?> NZBGet Web Interface 0) { echo ""; } if ($MiniJavaScript) { ?>
    NZBGet Web Interface v 1.4 (testing-2)