public static function format($rawLectureData) { extract($rawLectureData); $singleLectures = array(); $recurringLectures = array(); if (!empty($rawLectures)) { foreach ($rawLectures as $lecture) { if ($lecture['frequenz'] == "woche") { //linking matching comments $linkedComments = array(); foreach ($comments as $comment) { if ($comment['veranstaltungsID'] == $lecture['nr']) { $linkedComments[] = array("date" => convertDateToYYYYMMDD($comment['datum']), "text" => $comment['titel']); } } //converting to output format $recurringLectures[] = array("title" => $lecture['name'], "id" => $lecture['nr'], "type" => $lecture['kategorie'], "weekday" => dateToWeekday($lecture['startdatum']), "startTime" => convertTime($lecture['startzeit']), "endTime" => convertTime($lecture['endzeit']), "buildingId" => $lecture['gebäudeId'], "room" => $lecture['raumNr'], "comments" => $linkedComments); } else { if ($lecture['frequenz'] == "unique") { //linking matching comment (max 1, SingleLecture) $linkedComment = ""; foreach ($comments as $comment) { if ($comment['veranstaltungsID'] == $lecture['nr'] && $comment['datum'] == $lecture['startdatum']) { $linkedComment = $comment['titel']; } } //converting to output format $singleLectures[] = array("title" => $lecture['name'], "id" => $lecture['nr'], "type" => $lecture['kategorie'], "startTime" => convertTime($lecture['startzeit']), "endTime" => convertTime($lecture['endzeit']), "date" => convertDateToYYYYMMDD($lecture['startdatum']), "buildingId" => $lecture['gebäudeId'], "room" => $lecture['raumNr'], "comment" => $linkedComment); } } } } return array("recurringLectures" => $recurringLectures, "singleLectures" => $singleLectures); }
function tweetCollector($query, $from_pg, $to_pg) { $tweets = searchResult($query, $from_pg, $to_pg); $tweets = filterReTweets($tweets); $tweets = keepRequiredFields($tweets); $tweets = removeUnwantedChars($tweets); $tweets = convertTime($tweets); return $tweets; }
function getTitle($network, $time) { /* Gets a title from the titles table. */ global $con; try { $sql = "SELECT * FROM `titles` WHERE network = :network AND time = :time"; $sql = $con->prepare($sql); $time = convertTime($time); $time = $time . ":00"; $sql->bindParam(":time", $time); $sql->bindParam(":network", $network); $sql->execute(); return $sql->fetchAll(); } catch (PDOException $e) { echo $e; } }
function generateCaption($userId, $authToken, $videoUrl, $language = 'en-GB') { // after this function we have video file stored locally $fileName = getVideoAndReturnFileName($videoUrl); $jobId = uploadVideoAndReturnJobId($userId, $authToken, $fileName, $language); while (isset(getVideoTranslation($userId, $authToken, $jobId)->code)) { sleep(10); } $translationFile = getVideoTranslation($userId, $authToken, $jobId); $lineCharacterCounter = 0; $fileContent = "WEBVTT\n\n"; $line = ''; foreach ($translationFile->words as $word) { $name = $word->name; if ($lineCharacterCounter == 0 && $name == '.') { continue; } $duration = $word->duration; $time = $word->time; if ($lineCharacterCounter == 0) { $startTime = $time; } if ($name == '.') { $line .= $name; } else { $line .= ' ' . $name; } $lineCharacterCounter += strlen($name); $endTime = $time + $duration; if (35 <= $lineCharacterCounter) { $timing = "\n\n" . convertTime($startTime) . " --> " . convertTime($endTime) . "\n{$line}"; $fileContent .= $timing; $lineCharacterCounter = 0; $line = ''; } } $captionFile = getIdFromUrl($videoUrl); file_put_contents($captionFile . '.vtt', $fileContent); echo "Done"; }
by <a href="albumlist.php?artist=<?php echo urlencode($artistInfo['artist_name']); ?> "><?php echo $artistInfo['artist_name']; ?> </a> in album <a href="tracklist.php?album=<?php echo urlencode($albumInfo['album_title']); ?> "><?php echo $albumInfo['album_title']; ?> </a> added <?php echo convertTime($trackReturn['time_added']); ?> </div> <div id="player_<?php echo $i; ?> " class="player"> <a href="javascript:findPreview(<?php echo $i; ?> , '<?php echo addslashes($trackReturn['track_name']); ?> ');"><img src="images/play.png" width="45px" /></a> </div>
function PridatN() { // BEGIN function PridatDokument $id = $_GET["id"]; $odeslat = $_POST["odeslat"]; if ($id) { $sql = "Select * from zpravy where id=" . $id; $spojeni = MysqlSpojeni('intranet'); $res = PrSql($spojeni, $sql); $zaznam = mysqli_fetch_array($res); $nadpis = $zaznam["nadpis"]; $text = $zaznam["text"]; $zverejnitod = date("j.n.Y", strtotime($zaznam['zverejnitod'])); if ($zaznam['zverejnitdo']) { $zverejnitdo = date("j.n.Y", strtotime($zaznam['zverejnitdo'])); } $vlozil = $zaznam["vlozil"]; $nazevprilohy = $zaznam["nazevprilohy"]; } else { $nadpis = $_POST["nadpis"]; $text = $_POST["e1m1"]; $zverejnitod = $_POST["zverejnitod"]; $zverejnitdo = $_POST["zverejnitdo"]; $vlozil = $_POST["vlozil"]; $nazevprilohy = $_POST["nazevprilohy"]; } if ($odeslat) { if (!$text) { $chyba .= " text zprávy"; $carka = ","; } if (!$nadpis) { $chyba .= $carka . " nadpis zprávy "; $carka = ","; } if (!$zverejnitod) { $chyba .= $carka . " Datum zveřejnění "; $carka = ","; } } if ($odeslat && !$chyba) { $tmp_name = $_FILES["userfile"]["tmp_name"]; $name = $_FILES["userfile"]["name"]; if ($tmp_name) { $soubor = "./dokumenty/prilohy/" . $name; } $zverejnitod = convertTime('%Y-%m-%d', '%d.%m.%Y', $zverejnitod); if ($zverejnitdo) { $zverejnitdo = "'" . convertTime('%Y-%m-%d', '%d.%m.%Y', $zverejnitdo) . "'"; } else { $zverejnitdo = "null"; } if ($odeslat == "Uložit") { $nazevprilohy = "null"; if ($tmp_name) { $nazevprilohy = "'" . $_POST["nazevprilohy"] . "'"; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo "Soubor " . $_FILES['userfile']['name'] . " byl úspěšně nahrán.\n"; move_uploaded_file($tmp_name, $soubor); } else { echo "Přenos souboru se nedařil: "; echo "soubor '" . $_FILES['userfile']['tmp_name'] . "'."; } } $sql = "INSERT INTO zpravy (nadpis,text,zverejnitod,zverejnitdo,soubor,nazevprilohy,zverejnil,datumvlozeni) VALUES ('{$nadpis}','{$text}','{$zverejnitod}',{$zverejnitdo},'{$soubor}',{$nazevprilohy},'{$vlozil}',NOW())"; $spojeni = MysqlSpojeni('intranet'); $res = PrSql($spojeni, $sql); echo "Dokument byl úspěšně uložen."; } else { $id = $_POST["id"]; $tmp_name = $_FILES["userfile"]["tmp_name"]; $name = $_FILES["userfile"]["name"]; if ($tmp_name) { $soubor = "./dokumenty/prilohy/" . $name; } if ($tmp_name) { $sqlsoubor = ",soubor='{$soubor}'"; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo "Soubor " . $_FILES['userfile']['name'] . " byl úspěšně nahrán.\n"; move_uploaded_file($tmp_name, $soubor); } else { echo "Přenos souboru se nedařil: "; echo ",soubor '" . $_FILES['userfile']['tmp_name'] . "'."; } } else { $sqlsoubor = ""; } $sql = "UPDATE zpravy SET nadpis='{$nadpis}', text='{$text}', zverejnitod='{$zverejnitod}',zverejnitdo={$zverejnitdo} {$sqlsoubor} where id={$id}"; $spojeni = MysqlSpojeni('intranet'); $res = PrSql($spojeni, $sql); echo "Dokument byl úspěšně aktualizován."; } } else { $text = "Přidat"; $butt = "Uložit"; if ($id) { $text = "Editovat"; $butt = "Aktualizovat"; } ?> <h2><?php echo $text; ?> zprávu</h2> <?php if ($chyba) { ?> <h3>Nebyly zadány údaje : <?php echo $chyba; ?> </h3><?php } ?> <form name="dokument" ENCTYPE="multipart/form-data" method="post" action="?sekce=managment&pod=pridatz"> <table> <tr> <td>Nadpis zprávy :</td> <td><input name="nadpis" type="text" size="50" value="<?php echo $nadpis; ?> "></td> </tr> <tr> <td>Text zprávy :</td> <td> <div> <textarea id="elm1" name="e1m1" rows="15" cols="80" style="width: 80%" class="tinymce"> <?php echo $zaznam["text"]; ?> </textarea> </div> <!-- Some integration calls --> <a href="javascript:;" onclick="$('#elm1').tinymce().show();return false;">[Show]</a> <a href="javascript:;" onclick="$('#elm1').tinymce().hide();return false;">[Hide]</a> <a href="javascript:;" onclick="$('#elm1').tinymce().execCommand('Bold');return false;">[Bold]</a> <a href="javascript:;" onclick="alert($('#elm1').html());return false;">[Get contents]</a> <a href="javascript:;" onclick="alert($('#elm1').tinymce().selection.getContent());return false;">[Get selected HTML]</a> <a href="javascript:;" onclick="alert($('#elm1').tinymce().selection.getContent({format : 'text'}));return false;">[Get selected text]</a> <a href="javascript:;" onclick="alert($('#elm1').tinymce().selection.getNode().nodeName);return false;">[Get selected element]</a> <a href="javascript:;" onclick="$('#elm1').tinymce().execCommand('mceInsertContent',false,'<b>Hello world!!</b>');return false;">[Insert HTML]</a> <a href="javascript:;" onclick="$('#elm1').tinymce().execCommand('mceReplaceContent',false,'<b>{$selection}</b>');return false;">[Replace selection]</a> </td> </tr> <tr> <td>Zveřejnit od :</td> <td><input name="zverejnitod" class="tcal" value="<?php echo $zverejnitod; ?> " type="text" size="20"> <script language="JavaScript"> new tcal ({ // form name 'formname': 'dokument', // input name 'controlname': 'zverejnitod' }); </script> </td> </tr> <tr> <td>Zveřejnit do :</td> <td><input name="zverejnitdo" class="tcal" value="<?php echo $zverejnitdo; ?> " type="text" size="20"> <script language="JavaScript"> new tcal ({ // form name 'formname': 'dokument', // input name 'controlname': 'zverejnitdo' }); </script> </td> </tr> <?php if ($_SESSION["ip"] == '192.168.10.87') { ?> <tr> <td>Vložil : </td> <td> <select name="vlozil"> <option value="Bc. Ctibor Venus">Bc. Ctibor Venus</option> <option value="Vladimíra Urbášková">Vladimíra Urbášková</option> <option value="MUDr. Dagmar Maltová, MBA">MUDr. Dagmar Maltová, MBA</option> </select> </td> <?php } else { ?> <td>Vložil : </td> <td><input name="vlozil" type="text" size="50" value="<?php echo $SESSION["nazev"]; ?> "></td> <?php } ?> </tr> <tr> <td>Název přílohy :</td> <td><input name="nazevprilohy" type="text" size="50" value="<?php echo $nazevprilohy; ?> "></td> </tr> <tr> <td>Příloha :</td> <td><input type="file" name="userfile" ></td> </tr> <tr> <td colspan="2" align="center"><input name="odeslat" type="submit" value="<?php echo $butt; ?> "></td> </tr> </table> <input type="hidden" name="id" value="<?php echo $id; ?> "> </form> <?php } }
/** * process buffer * * @return boolean */ function _processBuffer() { // downtotal if (preg_match_all("/(\\d*)K\\s\\./i", $this->_buffer, $matches, PREG_SET_ORDER)) { $this->_downtotal = $matches[count($matches) - 1][1] * 1024; } // percent_done + down_speed + _speed if (preg_match_all("/(\\d*)%(\\s*)(.*)\\/s/i", $this->_buffer, $matches, PREG_SET_ORDER)) { $matchIdx = count($matches) - 1; // percentage $this->_percent_done = $matches[$matchIdx][1]; // speed $this->_down_speed = $matches[$matchIdx][3] . "/s"; // we dont want upper-case k $this->_down_speed = str_replace("KB/s", "kB/s", $this->_down_speed); // size as int + convert MB/s $sizeTemp = substr($this->_down_speed, 0, -5); if (is_numeric($sizeTemp)) { $this->_speed = intval($sizeTemp); if (substr($this->_down_speed, -4) == "MB/s") { $this->_speed = $this->_speed * 1024; $this->_down_speed = $this->_speed . " kB/s"; } } else { $this->_speed = 0; $this->_down_speed = "0.00 kB/s"; } } // time left $this->_time_left = $this->_size > 0 && $this->_speed > 0 ? convertTime(($this->_size - $this->_downtotal) / 1024 / $this->_speed) : '-'; // download done if (preg_match("/.*saved\\s\\[.*/", $this->_buffer)) { $this->_outputMessage("download complete. initializing shutdown...\n"); // return return true; } // return return false; }
function outputForecast($saddress, $city, $state, $sunit) { $googleurl = "https://maps.googleapis.com/maps/api/geocode/xml?key=AIzaSyDISWh9GHBOX2VYSgHw0969f-G6ShYYpMQ&address="; $address = $saddress . ',' . $city . ',' . $state; $geocodeurl = $googleurl . urlencode($address); try { $response_xml_data = @file_get_contents($geocodeurl); } catch (Exception $e) { echo '<script language="javascript">'; echo 'alert("', $e->getMessage(), '")'; echo '</script>'; return; } if ($response_xml_data == FALSE) { echo '<script language="javascript">'; echo 'alert("Fetching address failed.Please try again!")'; echo '</script>'; return; } $simplexml = simplexml_load_string($response_xml_data); $lats = $simplexml->xpath('//location/lat'); $lngs = $simplexml->xpath('//location/lng'); $formataddress = $simplexml->xpath('//status'); if (count($lats) == 0 || count($lngs) == 0 || strpos($formataddress[0], 'ZERO_RESULTS') == true) { echo '<div id="forecast" class="diverror">'; echo "<h2>No results returned!</h2>\n <h2>Please try another address.</h2>"; echo '</div>'; return; } $lat = $lats[0]; $lng = $lngs[0]; $forecasturl = "https://api.forecast.io/forecast/f2f049b51c218c7578dfccf9b55c2b08/"; $urlpram = $lat . ',' . $lng . '?units=' . $sunit . '&exclude=flags'; $forecasturl .= $urlpram; try { $response_xml_data = @file_get_contents($forecasturl); } catch (Exception $e) { echo '<script language="javascript">'; echo 'alert("', $e->getMessage(), '")'; echo '</script>'; return; } if ($response_xml_data == FALSE) { echo '<script language="javascript">'; echo 'alert("Fetching weather forcast failed.Please try again!")'; echo '</script>'; return; } $jsonObject = json_decode($response_xml_data, true); $wCondition = $jsonObject['currently']['summary']; $wTemp = convertTemp($jsonObject['currently']['temperature'], $sunit); $wicon = converticon($jsonObject['currently']['icon'], $wCondition); $wprecp = convertprecep($jsonObject['currently']['precipIntensity'], $sunit); $wprecprob = convertpercernt($jsonObject['currently']['precipProbability']); $wwspeed = convertwindspeed($jsonObject['currently']['windSpeed'], $sunit); $wdewpoint = round($jsonObject['currently']['dewPoint']); $whumid = convertpercernt($jsonObject['currently']['humidity']); if (isset($jsonObject['currently']['visibility'])) { $wvisib = convertvisibility($jsonObject['currently']['visibility'], $sunit); } else { $wvisib = convertvisibility(0, $sunit); } $wsunrise = convertTime($jsonObject['daily']['data'][0]['sunriseTime'], $jsonObject['timezone']); $wsunset = convertTime($jsonObject['daily']['data'][0]['sunsetTime'], $jsonObject['timezone']); echo '<div id="forecast" class="divtable"><h2>' . $wCondition . '</h2><h2>' . $wTemp . '</h2>' . $wicon; echo '<table><tr><td>Precipitation:</td><td>' . $wprecp . '</td></tr>'; echo '<tr><td>Chance of Rain:</td><td>' . $wprecprob . '</td></tr>'; echo '<tr><td>Wind Speed:</td><td>' . $wwspeed . '</td></tr>'; echo '<tr><td>Dew Point:</td><td>' . $wdewpoint . '</td></tr>'; echo '<tr><td>Humidity:</td><td>' . $whumid . '</td></tr>'; echo '<tr><td>Visibility:</td><td>' . $wvisib . '</td></tr>'; echo '<tr><td>Sunrise:</td><td>' . $wsunrise . '</td></tr>'; echo '<tr><td>Sunset:</td><td>' . $wsunset . '</td></tr></table></div>'; }
function getFlightHeader($outLeg, $inLeg, $triptype, $year) { $resultHeader = array(); $outTotalTravelTime = 0; $inTotalTravelTime = 0; $CI =& get_instance(); $CI->load->model('flyg_model'); for ($k = 0; $k < count($outLeg); $k++) { $outLegArray = array(); if (count($outLeg) == 1) { $outLegArray = $outLeg['@attributes']; } else { $outLegArray = $outLeg[$k]['@attributes']; } if (count($outLeg) == 1) { //$resultHeader['out']['dep'] = $outLegArray['departureCityCode']; //$resultHeader['out']['dest'] = $outLegArray['destinationCityCode']; $resultHeader['out']['dep'] = $CI->flyg_model->getAirportNameFromCode($outLegArray['departureCityCode']) . '(' . $outLegArray['departureCityCode'] . ')'; $resultHeader['out']['dest'] = $CI->flyg_model->getAirportNameFromCode($outLegArray['destinationCityCode']) . '(' . $outLegArray['destinationCityCode'] . ')'; $depFullDate = createFormatedDate($outLegArray['departureDate'], $year, $outLegArray['departureTime']); $resultHeader['out']['depdate'] = $depFullDate; $arrivalFullDate = createFormatedDate($outLegArray['arrivalDate'], $year, $outLegArray['arrivalTime']); $diff = abs(strtotime($arrivalFullDate) - strtotime($depFullDate)); $outTotalTravelTime = $outTotalTravelTime + $diff; } else { $depFullDate = createFormatedDate($outLegArray['departureDate'], $year, $outLegArray['departureTime']); $resultHeader['out']['depdate'] = $depFullDate; $arrivalFullDate = createFormatedDate($outLegArray['arrivalDate'], $year, $outLegArray['arrivalTime']); $diff = abs(strtotime($arrivalFullDate) - strtotime($depFullDate)); $outTotalTravelTime = $outTotalTravelTime + $diff; if ($k == 0) { //$resultHeader['out']['dep'] = $outLegArray['departureCityCode']; $resultHeader['out']['dep'] = $CI->flyg_model->getAirportNameFromCode($outLegArray['departureCityCode']); $resultHeader['out']['dep'] = $CI->flyg_model->getAirportNameFromCode($outLegArray['departureCityCode']) . '(' . $outLegArray['departureCityCode'] . ')'; } else { //$resultHeader['out']['dest'] = $outLegArray['destinationCityCode']; $resultHeader['out']['dest'] = $CI->flyg_model->getAirportNameFromCode($outLegArray['destinationCityCode']) . '(' . $outLegArray['destinationCityCode'] . ')'; } } } //$k = 0; $k < count($outLeg); $k++ if ($outTotalTravelTime != 0) { $resultHeader['out']['totalTravelTime'] = convertTime($outTotalTravelTime); } //$outTotalTravelTime != 0 if ($triptype == 'R' && $inLeg != '') { for ($k = 0; $k < count($inLeg); $k++) { $inLegArray = array(); if (count($inLeg) == 1) { $inLegArray = $inLeg['@attributes']; } else { $inLegArray = $inLeg[$k]['@attributes']; } if (count($inLeg) == 1) { //$resultHeader['in']['dep'] = $inLegArray['departureCityCode']; //$resultHeader['in']['dest'] = $inLegArray['destinationCityCode']; $resultHeader['in']['dep'] = $CI->flyg_model->getAirportNameFromCode($inLegArray['departureCityCode']) . '(' . $inLegArray['departureCityCode'] . ')'; $resultHeader['in']['dest'] = $CI->flyg_model->getAirportNameFromCode($inLegArray['destinationCityCode']) . '(' . $inLegArray['destinationCityCode'] . ')'; $depFullDate = createFormatedDate($inLegArray['departureDate'], $year, $inLegArray['departureTime']); $resultHeader['in']['depdate'] = $depFullDate; $arrivalFullDate = createFormatedDate($outLegArray['arrivalDate'], $year, $outLegArray['arrivalTime']); //$totalTravelTime = dateDifference($arrivalFullDate, $depFullDate); $diff = abs(strtotime($arrivalFullDate) - strtotime($depFullDate)); $inTotalTravelTime = $inTotalTravelTime + $diff; } else { $depFullDate = createFormatedDate($inLegArray['departureDate'], $year, $inLegArray['departureTime']); $resultHeader['in']['depdate'] = $depFullDate; $arrivalFullDate = createFormatedDate($inLegArray['arrivalDate'], $year, $inLegArray['arrivalTime']); //$totalTravelTime = dateDifference($arrivalFullDate, $depFullDate); $diff = abs(strtotime($arrivalFullDate) - strtotime($depFullDate)); $inTotalTravelTime = $inTotalTravelTime + $diff; if ($k == 0) { //$resultHeader['in']['dep'] = $inLegArray['departureCityCode']; $resultHeader['in']['dep'] = $CI->flyg_model->getAirportNameFromCode($inLegArray['departureCityCode']) . '(' . $inLegArray['departureCityCode'] . ')'; } else { //$resultHeader['in']['dest'] = $inLegArray['destinationCityCode']; $resultHeader['in']['dest'] = $CI->flyg_model->getAirportNameFromCode($inLegArray['destinationCityCode']) . '(' . $inLegArray['destinationCityCode'] . ')'; } } } //$k = 0; $k < count($inLeg); $k++ } //$triptype == 'R' if ($inTotalTravelTime != 0) { $resultHeader['in']['totalTravelTime'] = convertTime($inTotalTravelTime); } //$inTotalTravelTime != 0 return $resultHeader; }
$hours[] = explode(';', $hour); } $ret[$i]['hours'] = $hours; $ret[$i]['premiere'] = (int) $ret[$i]['premiere']; $ret[$i]['3d'] = (int) $ret[$i]['3d']; $ret[$i]['dubbing'] = (int) $ret[$i]['dubbing']; $ret[$i]['digital'] = (int) $ret[$i]['digital']; } $txt = json_encode($ret); if ($ret) { $db->insert('cache', array('id' => $city . $d, 'json' => $txt, 'date' => date('Y-m-d h:i:s'))); } } return $txt; } if ($_GET) { $db = DB::singleton(); $date = 0; if ($_GET['date']) { $date = $_GET['date']; } else { if ($_GET['plus']) { $date = convertTime((int) $_GET['plus'], true); } else { $date = convertTime(0, true); } } echo jsonCity(mysql_real_escape_string($_GET['city']), mysql_real_escape_string($date)); } else { echo jsonCities(); }
/** * convertTimeText * * @param $seconds * @return textual remaining time */ function convertTimeText($seconds) { $hour_fmt = convertTime($seconds); if ($hour_fmt == '-') { return '-'; } $parts = explode(':', $hour_fmt); if (count($parts) >= 4) { return $parts[0] . "d."; } elseif (count($parts) == 3) { return $parts[0] . "h."; } elseif (count($parts) == 2) { return $parts[0] . "m."; } else { return $parts[0] . "s."; } }
function displaySections($crs, $sched, $sem) { //convert the sections to a calendar-like 2D array $data = array(); $dept = substr($crs, 0, DEPTCODELEN) . "_{$sem}"; $result = Query("SHOW TABLES LIKE '{$dept}'"); if (!mysql_num_rows($result)) { return "Sorry, the course could not be found.<br>"; } $result = Query("SELECT DISTINCT * FROM {$dept} WHERE NAME='{$crs}'"); if (!mysql_num_rows($result)) { return "Sorry, the course could not be found.<br>"; } while (list($name, $section, $day, $start, $end, $loc) = mysql_fetch_row($result)) { // get the currently occupied timings to make it easier for // the student to see what could conflict $numconflicts = checkConflicts($sched, $sem, $name, $section, $day, $start, $end); $start = convertTime($start); $end = convertTime($end); if ($numconflicts) { $data[] = array($section, $day, $start, $end, $loc, 1); } else { $data[] = array($section, $day, $start, $end, $loc, 0); } } // dynamically generate the table in HTML $table = "<table class='records' border='1' align='center' \n\t\t\t\tcellspacing='0' cellpadding='2'>\n\t\t\t\t<tr><th>Section<th>Day<th>Start<th>End<th>Location</tr>"; $table .= "<tr><th colspan=5>Lectures</th></tr>"; // If a section occurs more than once a week, display its name as // a large cell spanning multiple rows for easier differentiation $last = FALSE; $leccount = 0; $tutcount = 0; $pracount = 0; for ($i = 0; $i < count($data); $i++) { $rowspan = 0; list($section, $day, $start, $end, $loc, $conf) = $data[$i]; if ($section[0] == 'T' && $tutcount == 0) { $table .= "<tr><th colspan=5>Tutorials</th></tr>"; } if ($section[0] == 'P' && $pracount == 0) { $table .= "<tr><th colspan=5>Practicals</th></tr>"; } $table .= "<tr>"; // track multiple occurences of section names and adjust rowspan for ($j = $i; $data[$j][0] !== $last && $j < count($data) && $data[$j][0] == $data[$i][0]; $j++) { $rowspan++; } if ($rowspan > 0) { $last = $section; $table .= "<td rowspan='{$rowspan}'>"; $table .= "<input type='radio' "; switch ($section[0]) { case 'L': $table .= "name='lec' "; $leccount++; $table .= $leccount == 1 ? "checked " : ""; break; case 'T': $table .= "name='tut' "; $tutcount++; $table .= $tutcount == 1 ? "checked " : ""; break; case 'P': $table .= "name='pra' "; $pracount++; $table .= $pracount == 1 ? "checked " : ""; break; default: break; } $table .= "value='{$section}'>{$section}</td>"; } if ($conf == 1) { $table .= "<td bgcolor='F1433F'>{$day}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$start}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$end}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$loc}</td>"; } else { $table .= "<td>{$day}</td><td>{$start}</td><td>{$end}</td><td>{$loc}</td>"; } $table .= "</tr>"; } $table .= "</table>"; return $table; }
/** * This method gets the list of transfer * * @return array */ function getTransferListArray() { global $cfg, $db, $transfers; $kill_id = ""; $lastUser = ""; $arUserTransfers = array(); $arListTransfers = array(); // settings $settings = convertIntegerToArray($cfg["index_page_settings"]); // sortOrder $sortOrder = tfb_getRequestVar("so"); if ($sortOrder == "") { $sortOrder = $cfg["index_page_sortorder"]; } // t-list $arList = getTransferArray($sortOrder); foreach ($arList as $transfer) { // init some vars $displayname = $transfer; $show_run = true; $transferowner = getOwner($transfer); $owner = IsOwner($cfg["user"], $transferowner); // stat $sf = new StatFile($transfer, $transferowner); // settings if (isset($transfers['settings'][$transfer])) { $settingsAry = $transfers['settings'][$transfer]; } else { $settingsAry = array(); if (substr($transfer, -8) == ".torrent") { // this is a t-client $settingsAry['type'] = "torrent"; $settingsAry['client'] = $cfg["btclient"]; } else { if (substr($transfer, -5) == ".wget") { // this is wget. $settingsAry['type'] = "wget"; $settingsAry['client'] = "wget"; } else { if (substr($transfer, -4) == ".nzb") { // this is nzbperl. $settingsAry['type'] = "nzb"; $settingsAry['client'] = "nzbperl"; } else { AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer); @error("Invalid Transfer", "", "", array($transfer)); } } } $settingsAry['hash'] = ""; $settingsAry["savepath"] = $cfg["enable_home_dirs"] != 0 ? $cfg["path"] . $transferowner . '/' : $cfg["path"] . $cfg["path_incoming"] . '/'; $settingsAry['datapath'] = ""; } // cache running-flag in local var. we will access that often $transferRunning = $sf->running; // cache percent-done in local var. ... $percentDone = $sf->percent_done; // --------------------------------------------------------------------- //XFER: update1: add upload/download stats to the xfer array if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { @Xfer::update1($transfer, $transferowner, $settingsAry['client'], $settingsAry['hash'], $sf->uptotal, $sf->downtotal); } // --------------------------------------------------------------------- // injects if (!file_exists($cfg["transfer_file_path"] . $transfer . ".stat")) { $transferRunning = 2; $sf->running = "2"; $sf->size = getTransferSize($transfer); injectTransfer($transfer); } // totals-preparation // if downtotal + uptotal + progress > 0 if ($settings[2] + $settings[3] + $settings[5] > 0) { $ch = ClientHandler::getInstance($settingsAry['client']); $transferTotals = $ch->getTransferTotalOP($transfer, $settingsAry['hash'], $sf->uptotal, $sf->downtotal); } // --------------------------------------------------------------------- // preprocess stat-file and get some vars $estTime = ""; $statusStr = ""; switch ($transferRunning) { case 2: // new $statusStr = 'New'; break; case 3: // queued $statusStr = 'Queued'; $estTime = 'Waiting'; break; default: // running + stopped // increment the totals if (!isset($cfg["total_upload"])) { $cfg["total_upload"] = 0; } if (!isset($cfg["total_download"])) { $cfg["total_download"] = 0; } $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($sf->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($sf->down_speed); // $estTime if ($transferRunning == 0) { $estTime = $sf->time_left; } else { if ($sf->time_left != "" && $sf->time_left != "0") { if ($cfg["display_seeding_time"] == 1 && $sf->percent_done >= 100) { $estTime = $sf->seedlimit > 0 && !empty($sf->up_speed) && intval($sf->up_speed[0]) > 0 ? convertTime(($sf->seedlimit / 100 * $sf->size - $sf->uptotal) / GetSpeedInBytes($sf->up_speed)) : '-'; } else { $estTime = $sf->time_left; } } } // $lastUser $lastUser = $transferowner; // $show_run + $statusStr if ($percentDone >= 100) { $statusStr = $transferRunning == 1 && trim($sf->up_speed) != "" ? 'Seeding' : 'Done'; $show_run = false; } else { if ($percentDone < 0) { $statusStr = 'Stopped'; $show_run = true; } else { $statusStr = 'Leeching'; } } break; } // --------------------------------------------------------------------- // fill temp array $transferAry = array(); // ================================================================ name array_push($transferAry, $transfer); // =============================================================== owner if ($settings[0] != 0) { array_push($transferAry, $transferowner); } // ================================================================ size if ($settings[1] != 0) { array_push($transferAry, @formatBytesTokBMBGBTB($sf->size)); } // =========================================================== downtotal if ($settings[2] != 0) { array_push($transferAry, @formatBytesTokBMBGBTB($transferTotals["downtotal"])); } // ============================================================= uptotal if ($settings[3] != 0) { array_push($transferAry, @formatBytesTokBMBGBTB($transferTotals["uptotal"])); } // ============================================================== status if ($settings[4] != 0) { array_push($transferAry, $statusStr); } // ============================================================ progress if ($settings[5] != 0) { $percentage = ""; if ($percentDone >= 100 && trim($sf->up_speed) != "") { $percentage = @number_format($transferTotals["uptotal"] / $sf->size * 100, 2) . '%'; } else { if ($percentDone >= 1) { $percentage = $percentDone . '%'; } else { if ($percentDone < 0) { $percentage = round($percentDone * -1 - 100, 1) . '%'; } else { $percentage = '0%'; } } } array_push($transferAry, $percentage); } // ================================================================ down if ($settings[6] != 0) { $down = ""; if ($transferRunning == 1) { $down = trim($sf->down_speed) != "" ? $sf->down_speed : '0.0 kB/s'; } array_push($transferAry, $down); } // ================================================================== up if ($settings[7] != 0) { $up = ""; if ($transferRunning == 1) { $up = trim($sf->up_speed) != "" ? $sf->up_speed : '0.0 kB/s'; } array_push($transferAry, $up); } // =============================================================== seeds if ($settings[8] != 0) { $seeds = $transferRunning == 1 ? $sf->seeds : ""; array_push($transferAry, $seeds); } // =============================================================== peers if ($settings[9] != 0) { $peers = $transferRunning == 1 ? $sf->peers : ""; array_push($transferAry, $peers); } // ================================================================= ETA if ($settings[10] != 0) { array_push($transferAry, $estTime); } // ============================================================== client if ($settings[11] != 0) { switch ($settingsAry['client']) { case "tornado": array_push($transferAry, "B"); break; case "transmission": array_push($transferAry, "T"); break; case "mainline": array_push($transferAry, "M"); break; case "azureus": array_push($transferAry, "A"); break; case "wget": array_push($transferAry, "W"); break; case "nzbperl": array_push($transferAry, "N"); break; default: array_push($transferAry, "U"); } } // --------------------------------------------------------------------- // Is this transfer for the user list or the general list? if ($owner) { array_push($arUserTransfers, $transferAry); } else { array_push($arListTransfers, $transferAry); } } //XFER: update 2 if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { @Xfer::update2(); } // ------------------------------------------------------------------------- // build output-array $retVal = array(); if (sizeof($arUserTransfers) > 0) { foreach ($arUserTransfers as $torrentrow) { array_push($retVal, $torrentrow); } } $boolCond = true; if ($cfg['enable_restrictivetview'] == 1) { $boolCond = $cfg['isAdmin']; } if ($boolCond && sizeof($arListTransfers) > 0) { foreach ($arListTransfers as $torrentrow) { array_push($retVal, $torrentrow); } } return $retVal; }
function parseSchedule($id, $city) { global $count, $movies_count, $db; $txts = array(); $dates = array(); $dats = array(); echo " Pobieranie treści stron\n"; for ($i = 0; $i < 3; $i++) { $dates[$i] = convertTime($i, false); $dats[$i] = convertTime($i, true); $txts[$i] = getHTMLandConvert('http://multikino.pl/pl/repertuar/' . $city . '/' . $dats[$i] . '/'); } echo " Parsowanie repertuaru...\n"; foreach ($txts as $i => $str) { $date = $dates[$i]; $dat = $dats[$i]; echo ' Data ' . $dat . "\n"; $re = array(); preg_match_all('/(<li class="genre-(.*?) "><a href="\\/pl\\/filmy\\/(.*?)\\/" class="image"><img src="(.*?)" alt="(.*?)"\\/>(.*?)<\\/a><div class="showings">(.*?)<\\/div><h2><a href="\\/pl\\/filmy\\/(.*?)\\/" class="title">(.*?)<\\/a><\\/h2>(.*?)<div><\\/div>(<span class="genre">(.*?)<\\/span>)?(.*?)(span class="duration">\\/ (.*?) min.<\\/span>)?<p class="text">(.*?)<\\/p>)/im', $str, $re); $results = array(); $i = 0; for ($i = 0; $i < sizeof($re[0]); $i++) { $results = array(); $results2 = array(); $movie_id = 0; $moviem_id = 0; $ff = array('-3d', '-strefa', '-platinium', '-2d', '3D', 'strefa', 'platinium', '2D', 'dubbing', 'napisy', '- ', ' -', '--'); $tt = array(''); $fromm = array(' ', ' ', ' ...', '...', '-'); $too = array(' ', ' ', '…', '…', '–'); var_dump($re[16][$i]); $results['permalink'] = str_ireplace($ff, $tt, $re[3][$i]); $results['title'] = str_ireplace($ff, $tt, $re[9][$i]); $results['title_localized'] = str_ireplace($ff, $tt, $re[9][$i]); $results['image'] = $re[4][$i]; $results['description'] = str_replace($fromm, $too, trim($re[16][$i])); $db->query('SELECT id FROM movies WHERE permalink="' . $results['permalink'] . '" LIMIT 0,1;'); $a = $db->fetch(); if (!$a) { $db->insert('movies', $results); $movie_id = $db->insert_id(); $movies_count++; echo ' Dodano film: ' . $results['title'] . "\n"; } else { $movie_id = $a['id']; $db->update('movies', $results, array('id' => $movie_id)); } $results2['multikino_id'] = $re[3][$i]; $results2['movie_id'] = $movie_id; $results2['duration'] = $re[15][$i]; $results2['premiere'] = 0; $results2['3d'] = 0; $results2['dubbing'] = 0; $results2['digital'] = 0; $results2['sport'] = 0; $results2['maraton'] = 0; $results2['age'] = 0; $results2['platinium'] = 0; if (strpos($re[10][$i], 'premiera') > 0) { $results2['premiere'] = 1; } else { if (strpos($re[10][$i], 'przedpremierowy') > 0) { $results2['premiere'] = 2; } } if (strpos($re[10][$i], 'maraton') > 0) { $results2['maraton'] = 1; } if (strpos($re[10][$i], '3D') > 0) { $results2['3d'] = 1; } if (strpos($re[10][$i], 'dubbing') > 0) { $results2['dubbing'] = 1; } if (strpos($re[10][$i], 'cyfrowy') > 0) { $results2['digital'] = 1; } if (strpos($re[10][$i], 'sport') > 0) { $results2['sport'] = 1; } if (strpos($re[3][$i], 'platinium') > 0) { $results2['platinium'] = 1; } if (strpos($re[10][$i], '15+') > 0) { $results2['age'] = 15; } else { if (strpos($re[10][$i], '18+') > 0) { $results2['age'] = 18; } else { if (strpos($re[10][$i], '12+') > 0) { $results2['age'] = 12; } else { if (strpos($re[10][$i], '7+') > 0) { $results2['age'] = 7; } } } } if ($results2['duration'] == '') { $results2['duration'] = 0; } $db->query('SELECT id FROM movies_multikino WHERE multikino_id="' . $re[3][$i] . '" AND duration=' . $results2['duration'] . ' AND digital=' . $results2['digital'] . ' AND premiere=' . $results2['premiere'] . ' AND 3d=' . $results2['3d'] . ' AND dubbing=' . $results2['dubbing'] . ' AND platinium=' . $results2['platinium'] . ' LIMIT 0,1;'); $a = $db->fetch(); try { if (!$a) { $db->insert('movies_multikino', $results2); $moviem_id = $db->insert_id(); $movies_count++; echo ' Dodano do multikina: ' . $results['title'] . "\n"; } else { $moviem_id = $a['id']; $db->update('movies_multikino', $a, array('id' => $moviem_id)); } } catch (Exception $e) { echo "Nie udało sie dodać filmu! :( " . $results['title']; var_dump($e); continue; } preg_match_all('/(<a (.*?)(zakup\\/(.*?)\\/(.*?))?>(.*?)<\\/a>)/i', $re[7][$i], $re2); $a = array(); for ($j = 0; $j < sizeof($re2[0]); $j++) { $s = trim($re2[6][$j]); if (!empty($re2[4][$j])) { $s .= ';' . $re2[4][$j]; } $a[] = $s; } try { $db->insert('schedule', array('id' => null, 'movie_id' => $moviem_id, 'hours' => implode(",", $a), 'date' => $dat, 'city_id' => $id)); $count++; } catch (Exception $e) { } } } }
} ?> </ul> </div> <div id="infobar"> <ul> <li><a href='mailto:tv.whuffie@spamgourmet.com'>Contact</a></li> <li><a href=''>About</a></li> <li><a href=''>FAQ</a></li> </ul> </div> </div> <div id="main"> <table id="ShowInformation"> <tbody class="tbody"> <?php layout_shows(convertTime(0) . " < endtime ", "starttime < " . convertTime(0), "On Now", 'now', 2, $client->getTimeFlag("now")); layout_shows(convertTime(0) . " < starttime ", "starttime < " . convertTime(2) . " AND starttime < " . convertDate(1), "Soon", 'soon', 3, $client->getTimeFlag("soon")); layout_shows(convertTime(2) . " < starttime ", "starttime < " . convertDate(1), "Later Today", 'later', 4, $client->getTimeFlag("later")); layout_shows(convertDate(1) . " < starttime ", "starttime < " . convertDate(2), "Tomorrow", 'tomorrow', 4, $client->getTimeFlag("tomorrow")); for ($c = 2; $c < 7; $c += 1) { $tmp = getdate(time() + $c * 24 * 60 * 60); layout_shows(convertDate($c) . " < starttime ", "starttime < " . convertDate($c + 1), "{$tmp['mday']} {$tmp['month']} {$tmp['year']}", "plus{$c}days", 5, 0); } ?> </tbody> </table> </div> </body> </html>
// increment the totals if (!isset($cfg["total_upload"])) { $cfg["total_upload"] = 0; } if (!isset($cfg["total_download"])) { $cfg["total_download"] = 0; } $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($sf->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($sf->down_speed); // $estTime if ($transferRunning == 0) { $estTime = $sf->time_left; } else { if ($sf->time_left != "" && $sf->time_left != "0") { if ($cfg["display_seeding_time"] == 1 && $sf->percent_done >= 100) { $estTime = $sf->seedlimit > 0 && !empty($sf->up_speed) && intval($sf->up_speed[0]) > 0 ? convertTime(($sf->seedlimit / 100 * $sf->size - $sf->uptotal) / GetSpeedInBytes($sf->up_speed)) : '-'; } else { $estTime = $sf->time_left; } } } // $show_run + $statusStr if ($percentDone >= 100) { $statusStr = trim($sf->up_speed) != "" && $transferRunning == 1 ? "Seeding" : "Done"; $show_run = false; } else { if ($percentDone < 0) { $statusStr = "Stopped"; $show_run = true; } else { $statusStr = "Leeching";
/** * process buffer * * @return boolean */ function _processBuffer() { // downtotal if (preg_match_all("/\\d*(K)/i", $this->_buffer, $matches, PREG_SET_ORDER)) { $matchIdx = count($matches) - 1; $res = preg_replace("/K/i", "", $matches[$matchIdx][0]); $this->_downtotal = (int) $res * 1024; } // percent_done if (preg_match_all("/\\d*(%)/i", $this->_buffer, $matches, PREG_SET_ORDER)) { $matchIdx = count($matches) - 1; $res = preg_replace("/%/i", "", $matches[$matchIdx][0]); $this->_percent_done = (int) $res; } // down_speed if (preg_match_all("/[0-9]*+[.]+[0-9]+/i", $this->_buffer, $matches, PREG_SET_ORDER)) { $matchIdx = count($matches) - 1; $this->_down_speed = $matches[$matchIdx][0] . " kB/s"; // size as int + convert MB/s $sizeTemp = substr($this->_down_speed, 0, -5); if (is_numeric($sizeTemp)) { $this->_speed = intval($sizeTemp); if (substr($this->_down_speed, -4) == "MB/s") { $this->_speed = $this->_speed * 1024; $this->_down_speed = $this->_speed . " kB/s"; } } else { $this->_speed = 0; $this->_down_speed = "0.00 kB/s"; } } // time left $this->_time_left = $this->_size > 0 && $this->_speed > 0 ? convertTime(($this->_size - $this->_downtotal) / 1024 / $this->_speed) : '-'; // download done if (preg_match("/.*saved\\s\\[.*/", $this->_buffer)) { $this->_outputMessage("download complete. initializing shutdown...\n"); // return return true; } // return return false; }
function getdaily($result, $unit) { $darray = $result['daily']['data']; $dobj = []; for ($i = 1; $i < count($darray); ++$i) { $table = array('Day' => date("l", $darray[$i]['time']), 'Month Date' => date("M d", $darray[$i]['time']), 'Icon Image' => converticon($darray[$i]['icon']), 'Min Temp' => convertTemp($darray[$i]['temperatureMin'], $unit), 'Max Temp' => convertTemp($darray[$i]['temperatureMax'], $unit), 'Summary' => $darray[$i]['summary'], 'Humidity' => convertpercernt($darray[$i]['humidity']), 'Visibility' => convertvisibility($darray[$i], $unit), 'Wind Speed' => convertwindspeed($darray[$i], $unit), 'Sunrise' => convertTime($darray[$i]['sunriseTime'], $result['timezone']), 'Sunset' => convertTime($darray[$i]['sunsetTime'], $result['timezone']), 'Pressure' => convertpressure($darray[$i]['pressure'], $unit)); array_push($dobj, $table); } return $dobj; }
?> " width="150" heigh="150" /> <?php // Grabs bio and cuts if the bio is too long // $cutBio = 0; $bioText = file_get_contents($DATABASE_SCRIPT_DIR . $DS_ALBUM_REVIEW_DIR . $albumReturn['review_file']); if (strlen($bioText) > $MAX_BIO_SIZE) { echo substr(file_get_contents($DATABASE_SCRIPT_DIR . $DS_ALBUM_REVIEW_DIR . $albumReturn['review_file']), 0, $MAX_BIO_SIZE) . "...<br /><a href=\"tracklist.php?album=" . urlencode($albumReturn['album_title']) . "\">(read more)</a>"; } else { echo file_get_contents($DATABASE_SCRIPT_DIR . $DS_ALBUM_REVIEW_DIR . $albumReturn['review_file']); } ?> </p> <?php echo convertTime($albumReturn['time_added']); ?> </div> <!-- gets fav system --> <div class="favcontainer clearfix"> <?php $curFav = favController("alb", "album", $dbHandle, $albumReturn, $curUserInfo, $MAX_SHOW_FAVOURATES); ?> </div> </div> <?php $i++; if ($i % 2 == 0 && $i >= 2) { echo "<br class=\"clear\">"; }
function loadNews() { $webClass = new WebClass(); $query = "SELECT * FROM 2s2h_news ORDER BY 2s2h_news.time DESC;"; /* get all articles here */ $result = $webClass->executeQuery($query); while ($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $author = $row['author']; $article = html_entity_decode($row['article']); /* need to decode, on database article is saved as html */ $date = $row['time']; echo "\n <div id=\"{$id}\" class=\"news-article\">\n <h3 class=\"title-art\">" . $title . " - <span>" . convertTime($date) . "</span></h3>\n <div>\n <p>" . $article . "</p>"; echo "<p class=\"auth\">By: " . $author . "</p>\n </div>\n </div>"; /* extra spacing between articles */ } $webClass->close(); }
function transmissionSetVars($transfer, $tmpl) { //require_once('inc/functions/functions.rpc.transmission.php'); require_once 'functions.rpc.transmission.php'; $options = array("eta", "percentDone", "rateDownload", "rateUpload", "downloadedEver", "uploadedEver", "percentDone", "sizeWhenDone", "peers", "trackerStats"); $returnArr = getTransmissionTransfer($transfer, $options); $tmpl->setvar('transferowner', getTransmissionTransferOwner($transfer)); $tmpl->setvar('size', @formatBytesTokBMBGBTB($returnArr['sizeWhenDone'])); // sharing $tmpl->setvar('sharing', $returnArr["downloadedEver"] > 0 ? @number_format($returnArr["uploadedEver"] / $returnArr["downloadedEver"] * 100, 2) : "0"); // totals $tmpl->setvar('downTotal', @formatFreeSpace($returnArr["downloadedEver"] / 1048576)); $tmpl->setvar('upTotal', @formatFreeSpace($returnArr["uploadedEver"] / 1048576)); // port + cons //$tmpl->setvar('size', @formatBytesTokBMBGBTB($transferSize)); $isRunning = true; // TODO make this actually detect if torrent is running if ($isRunning) { $tmpl->setvar('running', 1); // current totals $tmpl->setvar('downTotalCurrent', formatFreeSpace($totalsCurrent["downtotal"] / 1048576)); $tmpl->setvar('upTotalCurrent', formatFreeSpace($totalsCurrent["uptotal"] / 1048576)); // seeds + peers $seeds = getTransmissionSeederCount($transfer); $tmpl->setvar('seeds', $seeds == "" ? "Could not be retrieved" : $seeds . " (might be incorrect)"); $tmpl->setvar('peers', sizeof($returnArr['peers'])); // port + cons $transfer_pid = getTransferPid($transfer); $tmpl->setvar('port', netstatPortByPid($transfer_pid)); $tmpl->setvar('cons', netstatConnectionsByPid($transfer_pid)); // TODO: this is probably incorrect // up speed $tmpl->setvar('up_speed', trim($returnArr['rateUpload']) != "" ? formatBytesTokBMBGBTB($returnArr['rateUpload']) . '/s' : '0.0 kB/s'); // down speed $tmpl->setvar('down_speed', trim($returnArr['rateDownload']) != "" ? formatBytesTokBMBGBTB($returnArr['rateDownload']) . '/s' : '0.0 kB/s'); // sharekill $tmpl->setvar('sharekill', $ch->sharekill != 0 ? $ch->sharekill . '%' : '∞'); } else { // running $tmpl->setvar('running', 0); // current totals $tmpl->setvar('downTotalCurrent', ""); $tmpl->setvar('upTotalCurrent', ""); // seeds + peers $tmpl->setvar('seeds', ""); $tmpl->setvar('peers', ""); // port + cons $tmpl->setvar('port', ""); $tmpl->setvar('cons', ""); // up speed $tmpl->setvar('up_speed', ""); // down speed $tmpl->setvar('down_speed', ""); // sharekill $tmpl->setvar('sharekill', ""); } if ($returnArr['eta'] < 0) { $tmpl->setvar('time_left', 'n/a'); } else { $tmpl->setvar('time_left', convertTime($returnArr['eta'])); } // graph width $tmpl->setvar('graph_width1', $returnArr['percentDone'] * 100); $tmpl->setvar('graph_width2', 100 - $returnArr['percentDone'] * 100); $tmpl->setvar('percent_done', $returnArr['percentDone'] * 100); // language vars global $cfg; $tmpl->setvar('_USER', $cfg['_USER']); $tmpl->setvar('_SHARING', $cfg['_SHARING']); $tmpl->setvar('_ID_CONNECTIONS', $cfg['_ID_CONNECTIONS']); $tmpl->setvar('_ID_PORT', $cfg['_ID_PORT']); $tmpl->setvar('_DOWNLOADSPEED', $cfg['_DOWNLOADSPEED']); $tmpl->setvar('_UPLOADSPEED', $cfg['_UPLOADSPEED']); $tmpl->setvar('_PERCENTDONE', $cfg['_PERCENTDONE']); $tmpl->setvar('_ESTIMATEDTIME', $cfg['_ESTIMATEDTIME']); return $tmpl; }