Example #1
0
function formatItemDescription($torrent)
{
    global $theUILang;
    $desc = '<font size=2><fieldset><legend>' . $theUILang["Transfer"] . '</legend>' . '<strong>' . $theUILang["Size"] . ": </strong>" . bytes($torrent["size"]) . "<br>";
    if ($torrent["downloaded"] != $torrent["size"]) {
        $desc .= '<strong>' . $theUILang["Downloaded"] . ": </strong>" . bytes($torrent["downloaded"]) . "<br>";
    }
    if ($torrent["eta"] > 0) {
        $desc .= '<strong>' . $theUILang["Remaining"] . ": </strong>" . eta($torrent["eta"]) . "<br>";
    }
    if ($torrent["dl"] >= 1024) {
        $desc .= '<strong>' . $theUILang["Down_speed"] . ": </strong>" . speed($torrent["dl"]) . "<br>";
    }
    if ($torrent["uploaded"] > 0) {
        $desc .= '<strong>' . $theUILang["Uploaded"] . ": </strong>" . bytes($torrent["uploaded"]) . "<br>";
    }
    if ($torrent["ul"] >= 1024) {
        $desc .= '<strong>' . $theUILang["Ul_speed"] . ": </strong>" . speed($torrent["ul"]) . "<br>";
    }
    $desc .= '<strong>' . $theUILang["Share_ratio"] . ": </strong>" . $torrent["ratio"] . "<br>";
    if ($torrent["seeds"] != "0 (0)") {
        $desc .= '<strong>' . $theUILang["Seeds"] . ": </strong>" . $torrent["seeds"] . "<br>";
    }
    if ($torrent["peers"] != "0 (0)") {
        $desc .= '<strong>' . $theUILang["Peers"] . ": </strong>" . $torrent["peers"] . "<br>";
    }
    $desc .= "</fieldset>";
    if (!empty($torrent["mesage"])) {
        $desc .= '<fieldset><legend>' . $theUILang["Track_status"] . '</legend>' . htmlspecialchars($torrent["mesage"], ENT_COMPAT, "UTF-8") . '</fieldset>';
    }
    if (!empty($torrent["comment"])) {
        $desc .= '<fieldset><legend>' . $theUILang["Comment"] . '</legend>' . htmlspecialchars($torrent["comment"], ENT_COMPAT, "UTF-8") . '</fieldset>';
    }
    return $desc;
}
Example #2
0
function sidebar()
{
    $return .= "\n\t<h4>Music Library</h4>\n\t<dl>\n\t\t<dt>Tracks</dt>\n\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\n\t\t<dt>Artists</dt>\n\t\t<dd>" . number_format(Artists::count()) . "</dd>\n\t\t<dt>Albums</dt>\n\t\t<dd>" . number_format(Albums::count()) . "</dd>\n\t</dl>";
    function bytes($a)
    {
        $unim = array("B", "KB", "MB", "GB", "TB", "PB");
        $c = 0;
        while ($a >= 1024) {
            $c++;
            $a = $a / 1024;
        }
        return number_format($a, $c ? 2 : 0, ".", ",") . " " . $unim[$c];
    }
    $return .= "\n\t<h4>Archive Storage</h4>\n\t<dl>";
    foreach (Archives::get_all() as $archive) {
        $pc = (int) (100 - $archive->get_free_space() / $archive->get_total_space() * 100);
        if ($archive->get_free_space() > 536870912000.0) {
            $colour = "success";
        } else {
            if ($archive->get_free_space() > 214748364800.0) {
                $colour = "warning";
            } else {
                $colour = "danger";
            }
        }
        $return .= "\n\t\t<dt>" . $archive->get_name() . "</dt>\n\t\t<dd><div class=\"progress\" style=\"margin: 3px 0px; \"><div class=\"progress-bar progress-bar-" . $colour . "\" style=\"width: " . $pc . "%;\"></div></div></dd>\n\t\t<dd>" . bytes($archive->get_free_space()) . " free of " . bytes($archive->get_total_space()) . "</dd>";
    }
    $return .= "</dl>";
    return $return;
}
Example #3
0
 function check($sPath, $aContent = null)
 {
     $this->iCount++;
     $iFS = filesize($sPath);
     if ($iFS > MCS_MAXFS || $iFS > bytes(ini_get('post_max_size'))) {
         $this->lFiles[$sPath] = $iFS;
     }
     return $this->lFiles[$sPath] ? true : false;
 }
Example #4
0
function insert_timer($options)
{
    $timer = VTimer::get($options['magic']);
    return 'Rendered in ' . $timer['time'] . ', using ' . bytes($timer['memory']) . ' memory!';
}
Example #5
0
function writeLine($text)
{
    echo $text . "\t(" . bytes(memory_get_usage()) . ")" . "\t(" . bytes(memory_get_peak_usage()) . ")" . PHP_EOL;
}
        $last = '';
        foreach ($oos as $k2 => $t) {
            $len = ' (' . bytes($page_len[$k2]) . ')';
            $out .= '<li><a target="_blank" href="http://' . $language . '.wikipedia.org/w/index.php?redirect=no&title=' . urlencode($t) . '">';
            $out .= myenc($t) . "</a>{$len}</li>";
            $had_that[$t] = 1;
        }
        $out .= '</ol>';
        $guid = myenc("{$language}:{$d}:" . md5($out));
        print "<guid>{$guid}</guid>";
        print "<description>" . htmlspecialchars($out) . "</description>";
        print '</item>';
    } else {
        $list = '<ol>';
        foreach ($oos as $k2 => $t) {
            $len = ' (' . bytes($page_len[$k2]) . ')';
            if ($page_is_redirect[$k2]) {
                $len .= ' [REDIRECT]';
            }
            $list .= '<li><a target="_blank" href="' . get_wikipedia_url($language, 'Kategorie:' . $t) . '&redirect=no">';
            $list .= $t . "</a>{$len}</li>";
            $had_that[$t] = 1;
        }
        $list .= '</ol>';
        print "<li><a href=\"{$url}\" target='_blank'>{$catname}:{$d}</a>{$list}</li>";
        //	myflush () ;
    }
}
if ($mode == 'rss') {
    print '</channel></rss>';
} else {
Example #7
0
                    <td width="50%" class="border-bottom border-right">
                        <a href="<?php 
    echo page("torrent", "details", "", "", "", "id=" . $db->torrent_id);
    ?>
"><?php 
    echo $db->torrent_name;
    ?>
</a>
                    </td>
                    <td class="border-right border-bottom" align="center">
                        <?php 
    echo bytes($db->peer_uploaded);
    ?>
                    </td>
                    <td class="border-right border-bottom" align="center">
                        <?php 
    echo bytes($db->peer_downloaded);
    ?>
                    </td>
                    <td class="border-bottom" align="center">
                        <?php 
    echo timediff($db->peer_started, time());
    ?>
                    </td>
                </tr>
                <?php 
}
?>
        </tbody>
    </table>
</div>
Example #8
0
 /**
  * Get the amount of downloaded data
  * @return type 
  */
 function downloaded()
 {
     return bytes($this->_user['downloaded']);
 }
Example #9
0
    public function start($settings = array(), $local = '')
    {
        # Adding our nuquery javascript
        echo '<script type="text/javascript" id="nuquery-jssdk" src="', ($local == '' ? 'http://api.nuquery.com/' . self::script_version . '/nuquery.min.js' : $local) . '"></script>';
        # Adding our load scripts
        foreach ($this->load_scripts as $src) {
            echo '<script src="', $src, '"></script>';
        }
        # Adding the hosts
        if (defined('NQ_API_HOST_DATABASE')) {
            $settings['__dbhost'] = NQ_API_HOST_DATABASE;
        }
        if (defined('NQ_API_HOST_IMAGE')) {
            $settings['__imghost'] = NQ_API_HOST_IMAGE;
        }
        if (defined('NQ_API_HOST_FILE')) {
            $settings['__filehost'] = NQ_API_HOST_FILE;
        }
        if (defined('NQ_API_HOST_EMAIL')) {
            $settings['__emailhost'] = NQ_API_HOST_EMAIL;
        }
        # Convert string bytes to a number
        function bytes($val)
        {
            $val = trim($val);
            $last = strtolower($val[strlen($val) - 1]);
            # Switch will compound values (no breaks)
            switch ($last) {
                case 'g':
                    $val *= 1024;
                case 'm':
                    $val *= 1024;
                case 'k':
                    $val *= 1024;
            }
            # Returning the bytes
            return $val;
        }
        # Setting our app id, asny css and async javascript
        $settings['app_id'] = $this->owner->app_id;
        $settings['asyncCSS'] = isset($this->owner->css->stylesheets) ? $this->owner->css->stylesheets : [];
        $settings['asyncJavaScript'] = $this->async_scripts;
        $settings['maxUploadSize'] = min(bytes(ini_get('upload_max_filesize')), bytes(ini_get('post_max_size')));
        # Our init functionality
        echo '	<script type="text/javascript">
					nuQuery.ready(function(){
						nuQuery.init(', json_encode($settings), ');
					});
				</script>';
    }
Example #10
0
    $db = new DB("peers");
    $db->setColPrefix("peer_");
    $db->select("peer_torrent = '" . $db->escape($tid) . "' AND peer_seeder = '1'");
    $no_peers = true;
    if ($db->numRows()) {
        echo "<h4>" . _t("Seeders") . "</h4>";
        echo "\n        <table width='100%' class='forum' cellspacing='0' cellpadding='5'>\n        <thead>\n            <tr>\n                <td class='border-bottom border-right' width='200px'>Seeder</td>\n                <td class='border-bottom border-right'>Downloaded</td>\n                <td class='border-bottom border-right'>Uploaded</td>\n                <td class='border-bottom border-right' align='center'>Seeded for</td>\n            </tr>\n        </thead>\n        <tbody>\n        ";
        while ($db->nextRecord()) {
            $user = new Acl($db->userid);
            echo "\n            <tr>\n                <td class='border-bottom border-right'>" . (!$user->anonymous || $acl->Access("x") ? "<a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a>" : "Anonymous") . "</td>\n                <td class='border-bottom border-right'>" . bytes($db->downloaded) . "</td>\n                <td class='border-bottom border-right'>" . bytes($db->uploaded) . "</td>\n                <td class='border-bottom border-right' align='center'>" . timediff($db->started, time()) . "</td>\n            </tr>";
        }
        echo "</tbody></table>";
        $no_peers = false;
    }
    $db->select("peer_torrent = '" . $db->escape($tid) . "' AND peer_seeder = '0'");
    if ($db->numRows()) {
        echo "<h4>" . _t("Leechers") . "</h4>";
        echo "\n        <table width='100%' class='forum' cellspacing='0' cellpadding='5'>\n        <thead>\n            <tr>\n                <td class='border-bottom border-right' width='200px'>Leecher</td>\n                <td class='border-bottom border-right'>Downloaded</td>\n                <td class='border-bottom border-right'>Uploaded</td>\n                <td class='border-bottom border-right' align='center'>Leeching for</td>\n            </tr>\n        </thead>\n        <tbody>\n        ";
        while ($db->nextRecord()) {
            $user = new Acl($db->userid);
            echo "\n            <tr>\n                <td class='border-bottom border-right'>" . (!$user->anonymous || $acl->Access("x") ? "<a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a>" : "Anonymous") . "</td>\n                <td class='border-bottom border-right'>" . bytes($db->downloaded) . "</td>\n                <td class='border-bottom border-right'>" . bytes($db->uploaded) . "</td>\n                <td class='border-bottom border-right' align='center'>" . timediff($db->started, time()) . "</td>\n            </tr>";
        }
        echo "</tbody></table>";
        $no_peers = false;
    }
    if ($no_peers) {
        echo notice(_t("No Peers found"));
    }
} catch (Exception $e) {
    echo error(_t($e->getMessage()));
}
Example #11
0
 public function serialize(&$var)
 {
     if (!isset($var) || $var === NULL) {
         $this->writeNull();
     } elseif (is_scalar($var)) {
         if (is_int($var)) {
             if ($var >= 0 && $var <= 9) {
                 $this->stream->write((string) $var);
             } else {
                 $this->writeInteger($var);
             }
         } elseif (is_bool($var)) {
             $this->writeBoolean($var);
         } elseif (is_float($var)) {
             $this->writeDouble($var);
         } elseif (is_string($var)) {
             if ($var === '') {
                 $this->writeEmpty();
             } elseif (strlen($var) < 4 && is_utf8($var) && ustrlen($var) == 1) {
                 $this->writeUTF8Char($var);
             } elseif (is_utf8($var)) {
                 $this->writeStringWithRef($var);
             } else {
                 $this->writeBytesWithRef(bytes($var));
             }
         }
     } elseif (is_array($var)) {
         if (is_list($var)) {
             $this->writeListWithRef($var);
         } else {
             $m = map($var);
             $this->writeMapWithRef($m);
         }
     } elseif (is_object($var)) {
         if ($var instanceof stdClass) {
             $this->writeMapWithRef($var);
         } elseif ($var instanceof DateTime) {
             $this->writeDateTimeWithRef($var);
         } elseif ($var instanceof HproseDate || $var instanceof HproseDateTime) {
             $this->writeDateWithRef($var);
         } elseif ($var instanceof HproseTime) {
             $this->writeTimeWithRef($var);
         } elseif ($var instanceof HproseBytes) {
             $this->writeBytesWithRef($var);
         } elseif ($var instanceof HproseMap) {
             $this->writeMapWithRef($var);
         } else {
             $this->writeObjectWithRef($var);
         }
     } else {
         throw new Exception('Not support to serialize this data');
     }
 }
Example #12
0
        $folder_handle = opendir($path);
        $exclude_array = explode("|", $exclude);
        $result = array();
        while (false !== ($filename = readdir($folder_handle))) {
            if (!in_array(strtolower($filename), $exclude_array)) {
                if (is_dir($path . $filename . "/")) {
                    $result = array_merge($result, file_array($path . $filename, $exclude, $include));
                } else {
                    if (preg_match('`^' . strtr(preg_quote($include, '`'), array('\\*' => '.*?', '\\?' => '.')) . '$`i', $filename)) {
                        $result[] = $path . $filename;
                    }
                }
            }
        }
        return $result;
    }
    $existing_files = file_array($base_path);
    foreach ($existing_files as $curfile) {
        $curfile = str_replace($base_path, '', $curfile);
        if (!in_array($curfile, $update_files, true)) {
            $size = filesize($base_path . $curfile);
            if (unlink($base_path . $curfile)) {
                $removed_files++;
                $total_size += $size;
            } else {
                echo 'Could not remove unused file (' . $curfile . ').' . "\n";
            }
        }
    }
    echo 'Clean-up complete.' . ($removed_files > 0 ? ' ' . $removed_files . ' files in size of ' . bytes($total_size) . ' were removed.' : ' No files were removed.') . "\n";
}
 private function threadsBenchData()
 {
     if ($this->benchData && $this->threads) {
         $jsonReports = array();
         for ($i = 0; $i < $this->threads; ++$i) {
             $jsonOutput = sys_get_temp_dir() . '/memcached_slabs_' . time() . '_' . $i;
             $jsonReports[$i] = $jsonOutput;
             $command = 'php ' . $this->scriptFile . ' -j ' . $jsonOutput;
             foreach ($this->benchData as $benchDataSet) {
                 $benchDataSet[0] = round($benchDataSet[0] / $this->threads);
                 $benchDataSet[5] .= $i . '_';
                 $command .= ' -b ' . implode(':', $benchDataSet);
             }
             foreach ($this->instances as $instance) {
                 $command .= ' ' . implode(':', $instance);
             }
             //echo $command, PHP_EOL;
             exec($command . '>/dev/null &');
         }
         $stats = array();
         while ($jsonReports) {
             foreach ($jsonReports as $i => $jsonOutput) {
                 if (file_exists($jsonOutput)) {
                     $stats[] = json_decode(file_get_contents($jsonOutput), true);
                     unset($jsonReports[$i]);
                     unlink($jsonOutput);
                     echo '*';
                 }
             }
             echo '.';
             usleep(100000);
         }
         //print_r($stats);
         $log = array();
         $resultTimes = array();
         $total = array();
         foreach ($stats as $statData) {
             foreach ($statData as $stat) {
                 foreach ($stat as $test => $results) {
                     $log[$test][] = array($results['start'] - $this->now, $results['end'] - $this->now);
                     $resultTimes[$test][] = $results['end'] - $results['start'];
                     //print_r($results);
                     /*
                     $total[$test]['start'] = isset($total[$test]['start'])
                         ? min($results['start'], $total[$test]['start'])
                         : $results['start'];
                     
                     $total[$test]['end'] = isset($total[$test]['end'])
                         ? max($results['end'], $total[$test]['end'])
                         : $results['end'];
                     */
                     unset($results['start']);
                     unset($results['end']);
                     foreach ($results as $key => $value) {
                         if (!isset($total[$test][$key])) {
                             $total[$test][$key] = 0;
                         }
                         $total[$test][$key] += $value;
                     }
                 }
             }
         }
         ini_set('precision', 3);
         //print_r($log);
         if ($this->debug) {
             foreach ($log as $test => $times) {
                 echo $test, PHP_EOL;
                 foreach ($times as $time) {
                     echo $time[0], ' ', $time[1], ' ', $time[1] - $time[0], PHP_EOL;
                 }
             }
         }
         echo PHP_EOL;
         foreach ($total as $test => $result) {
             $result['time'] = array_sum($resultTimes[$test]) / count($resultTimes[$test]);
             echo $test, ': ', $result['count'] . ' items in ' . $result['time'] . ' s. (' . number_format($result['count'] / $result['time'], 2, '.', '') . ' items/s), ' . bytes($result['read']) . ' (' . bytes($result['read'] / $result['time']) . '/s) read, ' . bytes($result['write']) . ' (' . bytes($result['write'] / $result['time']) . '/s) written' . PHP_EOL;
         }
         exit;
     }
 }
Example #14
0
    echo $torrent->category();
    ?>
"></td><td></td></tr>
            <tr><td align="right"><b>Download</b></td><td><a href="<?php 
    echo page("torrent", "download", "", "", "", "torrent=" . $db->id);
    ?>
"><?php 
    echo $db->name;
    ?>
</a></td></tr>
            <tr><td align="right" valign="top"><b>Info</b></td><td><?php 
    echo htmlformat($db->nfo, true);
    ?>
</td></tr>
            <tr><td align="right"><b>Size</b></td><td><?php 
    echo bytes($db->size);
    ?>
</td></tr>
            <tr><td align="right"><b>Files</b></td><td><a href="<?php 
    echo page("torrent", "files", "", "", "", "torrent=" . $db->id);
    ?>
"><?php 
    echo $db->numfiles;
    ?>
</a></td></tr>
            <tr><td align="right"><b>Upped by</b></td><td>
                    <?php 
    if (!$acl->anonymous || $user->Access("x")) {
        echo "<a href='" . page("profile", "view", $acl->name) . "'>" . $acl->name . "</a>";
    } else {
        echo _t("Anonymous");
Example #15
0
<?php

try {
    if (!isset($_GET['torrent'])) {
        throw new Exception("missing id");
    }
    if (!intval($_GET['torrent'])) {
        throw new Exception("invalid id");
    }
    $id = $_GET['torrent'];
    $db = new DB("torrents");
    $db->select("torrent_id  = '" . $db->escape($id) . "'");
    if (!$db->numRows()) {
        throw new Exception("Could not find torrent");
    }
    $db->nextRecord();
    echo "<h4>" . $db->torrent_name . "</h4>";
    $db = new DB("torrents_files");
    $db->setColPrefix("file_");
    $db->setSort("file_name ASC");
    $db->select("file_torrent = '" . $db->escape($id) . "'");
    echo "\n        <table width='100%' class='forum' cellspacing='0' cellpadding='5'>\n            <thead>\n                <tr>\n                    <td class='border-bottom border-right' width='80%'>" . _t("Filename") . "</td>\n                    <td class='border-bottom'>" . _t("Size") . "</td>\n                </tr>\n            </thead>\n            <tbody>";
    while ($db->nextRecord()) {
        echo "<tr>\n                    <td class='border-bottom border-right' width='80%'>" . htmlformat($db->name) . "</td>\n                    <td class='border-bottom'>" . bytes($db->size) . "</td>\n                </tr>";
    }
    echo "</tbody></table>";
} catch (Exception $e) {
    echo error(_t($e->getMessage()));
}
Example #16
0
		array( 'page', 'revision' ), 
		array( 'page_id, page_namespace, rev_id, rev_user' ), 
		$where, 
		'archiveStatsData',
		array( 'ORDER BY' => 'page_id, rev_id') 
	);

	if ( $oRes ) {
		$count = $dbr->numRows( $oRes );
		$pages = array();
		echo "$count records found \n";
		if ( $count ) {
			while( $oRow = $dbr->fetchObject( $oRes ) ) {
				#echo (" $loop % $sloop = " . $loop % $sloop . " \n");
				if ( ( $loop % $sloop ) == 0 ) {
					echo ("$loop. sleep: " . $sleep . " " . bytes(memory_get_usage(true)) . " \n");
					sleep($sleep);
				}
				$event = 1;
				if ( !isset( $pages[ $oRow->page_id ] ) ) {
					$event = 2; $pages[ $oRow->page_id ] = 1;
				}
				if ( $usedb ) {
					insertScribeEvents( $wgCityId, $oRow->page_id, $oRow->rev_id, $serverName, $event);
				} else {
					#callScribeProducer($oRow->page_id, $oRow->page_namespace, $oRow->rev_id, $oRow->rev_user);
					callEditHook($oRow->page_id, $oRow->rev_id, $oRow->page_namespace, $oRow->rev_user, $serverName);
				}
				$loop++;
			}
			$dbr->freeResult( $oRes );
Example #17
0
 /**
  * convert UID to GlobalObjID for meeting requests
  *
  * @param string $uid iCal UID
  * @return binary GlobalObjId
  */
 public static function uid2globalObjId($uid)
 {
     $objid = base64_encode("‚àtÅ·‚à" . "" . "" . pack('V', 13 + bytes($uid)) . 'vCal-Uid' . "" . $uid . "");
     debugLog(__METHOD__ . "('{$uid}') returning '{$objid}'");
     return $objid;
 }
 private function output()
 {
     $verbosity = $this->getOutput()->getVerbosity();
     if ($verbosity > 1) {
         $this->comment('Removed:');
     }
     foreach ($this->bag as $file) {
         switch ($verbosity) {
             case 2:
                 if ($file->parentId === null) {
                     $this->info("\t" . $file->clientname);
                 }
                 break;
             case 3:
                 if ($file->parentId === null) {
                     $this->line("\t" . $file->disk . "\t" . "<info>" . $file->clientname . "</info>\t" . bytes($file->size));
                 }
                 break;
             case 4:
                 $this->line("\t" . $file->disk . "\t" . "<info>" . $file->clientname . "</info>\t" . bytes($file->size));
                 break;
         }
     }
 }
Example #19
0
function showUpload()
{
    $app = JFactory::getApplication('site');
    require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php';
    $db =& JFactory::getDBO();
    $user = JFactory::getUser();
    jimport('joomla.access.access');
    $userGroups = JAccess::getGroupsByUser($user->id, true);
    $document = JFactory::getDocument();
    $menu = JSite::getMenu();
    $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery');
    $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : '';
    $is_admin = array(7, 8);
    $document->setTitle(JText::_('COM_DATSOGALLERY_NEW_PICTURE'));
    if (JFolder::exists(JPATH_ROOT . DS . 'tmp' . DS . $user->id)) {
        JFolder::delete(JPATH_ROOT . DS . 'tmp' . DS . $user->id);
    }
    $document->addStyleSheet(JURI::root(true) . '/components/com_datsogallery/libraries/plupload/css/plupload.queue.css');
    $document->addStyleSheet(JURI::base(true) . '/components/com_datsogallery/libraries/shadowbox/shadowbox.css');
    $document->addScript(JURI::root(true) . '/components/com_datsogallery/libraries/plupload/js/plupload.full.js');
    $document->addScript(JURI::root(true) . '/components/com_datsogallery/libraries/plupload/js/jquery.plupload.queue.js');
    $document->addScript(JURI::base(true) . '/components/com_datsogallery/libraries/shadowbox/shadowbox.js');
    $sbinit = 'Shadowbox.init();';
    $document->addScriptDeclaration($sbinit);
    createNewMemberAlbum();
    $db->setQuery('SELECT COUNT(id) FROM #__datsogallery WHERE owner_id = ' . (int) $user->id);
    $count_pic = $db->loadResult();
    if (in_array(2, $userGroups)) {
        $uplimit = $ad_acl_registered - $count_pic;
        if ($count_pic >= $ad_acl_registered) {
            $app->redirect(JRoute::_("index.php?option=com_datsogallery&amp;task=userpanel" . $itemid, false), JText::_('COM_DATSOGALLERY_MAY_ADD_MAX_OFF') . ' ' . $ad_acl_registered . ' ' . JText::_('COM_DATSOGALLERY_PICTURES'));
        }
    } else {
        if (in_array(3, $userGroups)) {
            $uplimit = $ad_acl_author - $count_pic;
            if ($count_pic >= $ad_acl_author) {
                $app->redirect(JRoute::_("index.php?option=com_datsogallery&amp;task=userpanel" . $itemid, false), JText::_('COM_DATSOGALLERY_MAY_ADD_MAX_OFF') . ' ' . $ad_acl_author . ' ' . JText::_('COM_DATSOGALLERY_PICTURES'));
            }
        } else {
            if (in_array(4, $userGroups)) {
                $uplimit = $ad_acl_editor - $count_pic;
                if ($count_pic >= $ad_acl_editor) {
                    $app->redirect(JRoute::_("index.php?option=com_datsogallery&amp;task=userpanel" . $itemid, false), JText::_('COM_DATSOGALLERY_MAY_ADD_MAX_OFF') . ' ' . $ad_acl_editor . ' ' . JText::_('COM_DATSOGALLERY_PICTURES'));
                }
            } else {
                if (in_array(5, $userGroups)) {
                    $uplimit = $ad_acl_publisher - $count_pic;
                    if ($count_pic >= $ad_acl_publisher) {
                        $app->redirect(JRoute::_("index.php?option=com_datsogallery&amp;task=userpanel" . $itemid, false), JText::_('COM_DATSOGALLERY_MAY_ADD_MAX_OFF') . ' ' . $ad_acl_publisher . ' ' . JText::_('COM_DATSOGALLERY_PICTURES'));
                    }
                } else {
                    if (array_intersect($is_admin, $userGroups)) {
                        $uplimit = 0;
                        $count_pic = false;
                    } else {
                        $app->redirect(JRoute::_("index.php?option=com_datsogallery&task=userpanel" . $itemid, false), "Contact Administrator");
                    }
                }
            }
        }
    }
    $format = '%s %s <br />%s';
    $finfo = sprintf($format, JText::_('COM_DATSOGALLERY_SHOWUPLOAD_5'), format_filesize($ad_maxfilesize), JText::_('COM_DATSOGALLERY_SHOWUPLOAD_7'));
    $document->addCustomTag("<script type=\"text/javascript\">var uplimit = " . $uplimit . ";</script>");
    $flimit = '%s %s <span style="color:#CC0000">%s</span> %s';
    if (!array_intersect($is_admin, $userGroups)) {
        $add_files = sprintf($flimit, JText::_('COM_DATSOGALLERY_ADD_FILES_TO_UPLOAD'), JText::_('COM_DATSOGALLERY_ADD_FILES_LIMIT'), $uplimit, JText::_('COM_DATSOGALLERY_FILES'));
    } else {
        $add_files = JText::_('COM_DATSOGALLERY_ADD_FILES_TO_UPLOAD');
    }
    $resize = $ad_max_wh ? 'resize: { width: ' . $ad_max_wu . ', height: ' . $ad_max_hu . ', quality: 100 },' : '';
    $msie = strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') ? true : false;
    $chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome') ? true : false;
    if ($msie) {
        $runtimes = "runtimes: 'flash,silverlight',\n";
    } elseif ($chrome) {
        $runtimes = "runtimes: 'flash,gears,html5',\n";
    } else {
        $runtimes = "runtimes: 'flash,html5,silverlight',\n";
    }
    $extensions = $ad_allow_zip ? 'jpg,jpeg,gif,png,zip' : 'jpg,jpeg,gif,png';
    ?>
<style type="text/css">
    fieldset { border:none; width:100%;}
    label { display:block; margin:15px 0 5px;}
    input.error { background: #f8dbdb; border-color: #e77776; }
</style>

<script type="text/javascript">
    plupload.addI18n({
        'Select files': '<?php 
    echo JText::_('COM_DATSOGALLERY_SELECT_FILES');
    ?>
',
        'Add files to the upload queue and click the start button.': '<div id="up_methods"><?php 
    echo JText::_('COM_DATSOGALLERY_UPLOAD_STEP_ONE_FILES_TYPE');
    ?>
</div><?php 
    echo $add_files;
    ?>
',
        'Filename': '<?php 
    echo JText::_('COM_DATSOGALLERY_FILENAME');
    ?>
',
        'Status': '<?php 
    echo JText::_('COM_DATSOGALLERY_STATUS');
    ?>
',
        'Size': '<?php 
    echo JText::_('COM_DATSOGALLERY_FILESIZE');
    ?>
',
        'Add files': '<?php 
    echo JText::_('COM_DATSOGALLERY_ADD_FILES');
    ?>
',
        'Add files.': '<?php 
    echo JText::_('COM_DATSOGALLERY_ADD_FILES');
    ?>
.',
        'Stop current upload': '<?php 
    echo JText::_('COM_DATSOGALLERY_STOP_UPLOAD');
    ?>
',
        'Start uploading queue': '<?php 
    echo JText::_('COM_DATSOGALLERY_START_UPLOADING');
    ?>
',
        'Start upload': '<?php 
    echo JText::_('COM_DATSOGALLERY_START_UPLOAD');
    ?>
',
        'Drag files here.': '<?php 
    echo JText::_('COM_DATSOGALLERY_DRAG_FILES_HERE');
    ?>
',
        'N/A': '<?php 
    echo JText::_('COM_DATSOGALLERY_NA');
    ?>
',
        'Uploaded %d/%d files': '<?php 
    echo JText::_('COM_DATSOGALLERY_UPLOADED');
    ?>
 %d/%d <?php 
    echo JText::_('COM_DATSOGALLERY_FILES');
    ?>
'
    });

    datso(function () {
        uploader = datso("#stepone").pluploadQueue({
            <?php 
    echo $runtimes;
    ?>
            url: '<?php 
    echo JURI::root();
    ?>
index.php?option=com_datsogallery&task=uploading',
            flash_swf_url: '<?php 
    echo JURI::root(true);
    ?>
/components/com_datsogallery/libraries/plupload/js/plupload.flash.swf',
            silverlight_xap_url : '<?php 
    echo JURI::root(true);
    ?>
/components/com_datsogallery/libraries/plupload/js/plupload.silverlight.xap',
            max_file_size : '<?php 
    echo bytes($ad_maxfilesize);
    ?>
',
	     	chunk_size : '500kb',
		    unique_names : false,
            dragdrop : true,
            <?php 
    echo $resize;
    ?>
            filters: [
            {title: '<?php 
    echo JText::sprintf('COM_DATSOGALLERY_ALLOWED_EXTENSIONS', $extensions);
    ?>
', extensions: '<?php 
    echo $extensions;
    ?>
'}
            ]
        });
        var uploader = datso('#stepone').pluploadQueue();
        <?php 
    if (!array_intersect($is_admin, $userGroups)) {
        ?>
        uploader.bind('QueueChanged', function (up, files) {
            if (up.files.length > uplimit) {
                up.splice(0, 1);
            }
        });
        <?php 
    }
    ?>

        uploader.bind('FileUploaded', function (up, file, res) {

            if (this.total.queued == 0) {
                datso('#stepone').delay(1000).fadeOut().slideUp(300);
                datso('#steptwo').delay(1400).fadeIn().slideDown(300);
            }
        });
    });

    function checkForm() {
        var form = document.upForm;
        if (form.catid.value == '0') {
            alert("<?php 
    echo JText::_('COM_DATSOGALLERY_MUST_SELECT_CATEGORY');
    ?>
");
            return false;
        } else if (form.gentitle.value == '') {
            alert("<?php 
    echo JText::_('COM_DATSOGALLERY_MUST_HAVE_TITLE');
    ?>
");
            return false;
        } else {
            datso('#catname').attr('disabled', false);
            document.upForm.action = 'index.php';
            document.upForm.submit();
        }
    }
</script>
<div class="dg_body_background_upload" style="min-height: 480px">
<form method="post" name="upForm">
      <div class="container">
        <fieldset id="stepone" class="plupload_header_title">
          <p><?php 
    echo JText::_('COM_DATSOGALLERY_BROWSER_SUPPORT');
    ?>
</p>
        </fieldset>

        <fieldset id="steptwo">
        <div class="plupload_header_title"><?php 
    echo JText::_('COM_DATSOGALLERY_STEP_TWO');
    ?>
</div>
        <div class="plupload_header_text"><?php 
    echo JText::_('COM_DATSOGALLERY_STEP_TWO_TEXT');
    ?>
</div>
            <span id="res">
            <?php 
    echo '<label for="catid">' . JText::_('COM_DATSOGALLERY_SELECT_CATEGORY') . ' *</label>';
    $catid = $app->getUserStateFromRequest("catid.com_datsogallery", 'catid', 0, 'int');
    echo ShowDropDownCategoryList('', 'catid', 'id="catnames" onchange="userCat(this.value);" style="width:340px"');
    echo dgTip(JText::_('COM_DATSOGALLERY_ASSIGN_TO_TIP'));
    ?>
            </span>
            <div id="usercat">
            <label for="name"><?php 
    echo JText::_('COM_DATSOGALLERY_CATEGORY_NAME');
    ?>
 *</label>
            <input type="text" id="name" name="name" style="width:330px" /> <span id="ucattip"> <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_CATEGORY_NAME_TIP'));
    ?>
 </span><span id="nameerr" style="display:none"> <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_CATEGORY_ALREADY_EXIST'), 'dg-exclamation-icon.png');
    ?>
 </span><span id="maxcaterr" style="display:none"> <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_MAX_CAT_EXHAUSTED'), 'dg-exclamation-icon.png');
    ?>
 </span>
            <label for="description"><?php 
    echo JText::_('COM_DATSOGALLERY_DESCRIPTION');
    ?>
</label>
            <textarea class="inputbox" cols="35" rows="4" id="description" name="description" style="width:338px"></textarea> <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_CATEGORY_DESCRIPTION_TIP'));
    ?>
              <p><span id="catnameResult"></span> <button id="create_dg_btn" class="dg_btn" type="button"><span><span><?php 
    echo JText::_('COM_DATSOGALLERY_CREATE');
    ?>
</span></span></button></p>
            </div>
            <div id="imagefields">
            <label for="gentitle"><?php 
    echo JText::_('COM_DATSOGALLERY_GENERIC_TITLE');
    ?>
 *</label>
            <input type="text" name="gentitle" style="width:330px" />
                <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_GENERIC_TITLE_TIP'));
    ?>
            <label for="gendesc"><?php 
    echo JText::_('COM_DATSOGALLERY_GENERIC_DESCRIPTION');
    ?>
</label>
            <textarea class="inputbox" cols="35" rows="4" name="gendesc" style="width:338px"></textarea>
                <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_GENERIC_DESCRIPTION_TIP'));
    ?>
            <label for="genimgauthor"><?php 
    echo JText::_('COM_DATSOGALLERY_AUTHOR');
    ?>
</label>
            <input type="text" name="genimgauthor" style="width:330px" />
                <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_IMAGE_AUTHOR_TIP'));
    ?>
            <label for="genimgauthorurl"><?php 
    echo JText::_('COM_DATSOGALLERY_AUTHOR_URL');
    ?>
</label>
            <input type="text" name="genimgauthorurl" style="width:330px" />
            <?php 
    echo dgTip(JText::_('COM_DATSOGALLERY_IMAGE_AUTHOR_URL_TIP'));
    ?>
            <p>
            <?php 
    $disabled = $ad_terms ? 'disabled="disabled" ' : '';
    if ($ad_terms) {
        ?>
                  <a rel="shadowbox;width=460;height=600" href="index.php?option=com_content&view=article&id=<?php 
        echo @$ad_terms_id;
        ?>
&tmpl=component&print=1&layout=default" title="<?php 
        echo @$ad_terms_name;
        ?>
"><?php 
        echo @$ad_terms_name;
        ?>
</a>
                  <input style="vertical-align: middle" type="checkbox" id="toggleElement" onchange="toggleStatus()"; />
                  <?php 
    }
    ?>
                  <button id="enable_dg_btn" <?php 
    echo $disabled;
    ?>
class="dg_btn" type="submit" onclick="checkForm();return false;"><span><span><?php 
    echo JText::_('COM_DATSOGALLERY_SEND');
    ?>
</span></span></button></p></div>
        </fieldset>

</div>
<input type="hidden" name="option" value="com_datsogallery" />
<input type="hidden" name="task" value="upload" />
<?php 
    echo JHTML::_('form.token');
    ?>
</form>
</div>
<?php 
}
if (!empty($_GET['city'])) {
    ?>
                                 
		<header><h1>Licensing and other data about <?php 
    print $safeLocation;
    ?>
</h1></header> 
	   
		<section class="tests">
		<header><h1>Broadband tests</h1></header>
		<dl>
		<?php 
    foreach ($tests as $test => $value) {
        //explodeCase changes camel case to an array, implode puts it back into a sentence.  and then uppercase first letter
        $testFormatted = ucwords(implode(' ', explodeCase($test, false)));
        $valueFormatted = bytes($value);
        // show kb or mb if appropriate
        print "<dt>{$testFormatted}</dt><dd>{$valueFormatted}</dd>";
    }
    ?>
		
		</dl>
		<p>This section is powered by the FCC's Broadband Test API</p>
		</section>  
		<?php 
}
?>
		
		
	 
		
 public function testBytesAreInMetricStystem()
 {
     $this->assertInstanceOf('ByteUnits\\Metric', bytes(1));
 }
Example #22
0
// Use curl to get listings from tele
$shows = array();
$json = array();
try {
    $ch = curl_init("http://" . $server_config['tele-ip'] . ':' . $server_config['tele-port']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    $lines = explode("\n", $data);
    $show = array();
    $prevTitle = '';
    foreach ($lines as $line) {
        // Parse relevant details from line
        preg_match('/\\"\\>\\<code\\>([0-9\\.]+)(B|k|M|G|T)\\<\\/code\\>.*\\>(.*)_.*_(\\d+)_(\\d+)_(\\d+)_(\\d+)_(\\d+)_(\\d+).*?wtv/', $line, $matches);
        if ($matches) {
            // Parse details
            $size = bytes($matches[1], $matches[2]);
            $title = $matches[3];
            $date = new DateTime($matches[4] . '-' . $matches[5] . '-' . $matches[6] . ' ' . $matches[7] . ':' . $matches[8] . ':' . $matches[9]);
            // Check if it's a new show
            if ($title != $prevTitle) {
                if ($prevTitle != '') {
                    $shows[] = $show;
                }
                $show = array('title' => $title, 'episodes' => array());
                $prevTitle = $title;
            }
            // Add this episode
            $show['episodes'][] = array('date' => $date->format('D, M j, Y'), 'timestamp' => $date->getTimeStamp(), 'size' => $size);
        }
    }
    // Add in last show
Example #23
0
    echo $torrent->category();
    ?>
"></td><td></td></tr>
            <tr><td align = "right"><b>Download</b></td><td><a href="<?php 
    echo page("torrent", "download", "", "", "", "torrent=" . $db->torrent_id);
    ?>
"><?php 
    echo $db->torrent_name;
    ?>
</a></td></tr>
            <tr><td align="right" valign="top"><b>Info</b></td><td><?php 
    echo htmlformat($db->torrent_nfo, true);
    ?>
</td></tr>
            <tr><td align="right"><b>Size</b></td><td><?php 
    echo bytes($db->torrent_size);
    ?>
</td></tr>
            <tr><td align="right"><b>Files</b></td><td><a href="<?php 
    echo page("torrent", "files", "", "", "", "torrent=" . $db->torrent_id);
    ?>
"><?php 
    echo $db->torrent_numfiles;
    ?>
</a></td></tr>
            <tr><td align="right"><b>Upped by</b></td><td>
                    <?php 
    if (!$acl->anonymous || $user->Access("x")) {
        echo "<a href='" . page("profile", "view", $acl->name) . "'>" . $acl->name . "</a>";
    } else {
        echo _t("Anonymous");
Example #24
0
 function writeDoubleBE($v, $i)
 {
     $bytes = bytes($v, DOUBLEV);
     $i = $this->normalize($i, false);
     foreach ($bytes as $idx => $b) {
         $this->writeUInt8($b, $i + $idx);
     }
     return $i + 8;
 }
Example #25
0
 public function testBoxAnInteger()
 {
     $this->assertEquals(bytes(42), box(42));
 }