Пример #1
0
 /**
  * \brief test for HumanSize
  */
 function test_HumanSize()
 {
     print "test function HumanSize()\n";
     $result = HumanSize(1024 * 1024 * 1024);
     $this->assertEquals("1 GB", $result);
     $result = HumanSize(10240);
     $this->assertEquals("10 KB", $result);
     $result = HumanSize(1024 * (1024 * 99 + 511));
     $this->assertEquals("99.5 MB", $result);
 }
Пример #2
0
	$row =& $lAdmin->AddRow($BUCKET_ID.'_'.$f_NAME, $Elem);

	$c = $arParts[$BUCKET_ID.$f_NAME];
	if ($c > 1)
	{
		$parts = ' ('.GetMessage("MAIN_DUMP_PARTS").$c.')';
		$size = $arSize[$f_NAME];
	}
	else
	{
		$parts = '';
		$size = $f_SIZE;
	}

	$row->AddField("NAME", '<img src="/bitrix/images/fileman/types/'.CFileMan::GetFileTypeEx($f_NAME).'.gif" width="16" height="16" border=0 alt="">&nbsp;'.$f_NAME.$parts);
	$row->AddField("SIZE", HumanSize($size));
	$row->AddField("PLACE", $f_PLACE ? $f_PLACE : GetMessage("MAIN_DUMP_LOCAL"));
	$row->AddField("DATE", $f_DATE);

	$arActions = Array();

	if ($f_PERMISSION >= "R")
	{
		$arActions[] = array(
			"ICON" => "download",
			"DEFAULT" => true,
			"TEXT" => GetMessage("MAIN_DUMP_ACTION_DOWNLOAD"),
			"ACTION" => "AjaxSend('?action=download&f_id=".$f_NAME."&BUCKET_ID=".$BUCKET_ID."&".bitrix_sessid_get()."')"
		);
		$arActions[] = array(
			"ICON" => "link",
Пример #3
0
 /**
  * \brief Database metrics
  * \returns html table containing metrics
  */
 function DatabaseMetrics()
 {
     global $PG_CONN;
     $V = "<table border=1>\n";
     $text = _("Metric");
     $text1 = _("Total");
     $V .= "<tr><th>{$text}</th><th>{$text1}</th></tr>\n";
     /* Database size */
     $sql = "SELECT pg_database_size('fossology') as val;";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $Size = HumanSize($row['val']);
     pg_free_result($result);
     $text = _("FOSSology database size");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'> {$Size} </td></tr>\n";
     /**** Version ****/
     $text = _("Postgresql version");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'> {$this->pgVersion[server]} </td></tr>\n";
     /**** Query stats ****/
     // count current queries
     $sql = "SELECT count(*) AS val FROM pg_stat_activity";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $connection_count = '';
     $connection_count = $row['val'];
     pg_free_result($result);
     /**** Active connection count ****/
     $current_query = strcmp($this->pgVersion['server'], "9.2") >= 0 ? "state" : "current_query";
     $text = _("Active database connections");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'>" . number_format($connection_count, 0, "", ",") . "</td></tr>\n";
     $sql = "SELECT count(*) AS val FROM pg_stat_activity WHERE {$current_query} != '<IDLE>' AND datname = 'fossology'";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $item_count = $row['val'];
     pg_free_result($result);
     $V .= "</table>\n";
     return $V;
 }
Пример #4
0
 /**
  * \brief Display the info data associated with the file.
  */
 function ShowView($Upload, $Item, $ShowMenu = 0)
 {
     global $PG_CONN;
     $V = "";
     if (empty($Upload) || empty($Item)) {
         return;
     }
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     $Max = 50;
     /**********************************
        List File Info
        **********************************/
     if ($Page == 0) {
         $text = _("Repository Locator");
         $V .= "<H2>{$text}</H2>\n";
         $sql = "SELECT * FROM uploadtree\n        INNER JOIN pfile ON uploadtree_pk = {$Item}\n        AND pfile_fk = pfile_pk\n        LIMIT 1;";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $R = pg_fetch_assoc($result);
         pg_free_result($result);
         $V .= "<table border=1>\n";
         $text = _("Attribute");
         $text1 = _("Value");
         $V .= "<tr><th>{$text}</th><th>{$text1}</th></tr>\n";
         $Bytes = $R['pfile_size'];
         $BytesH = HumanSize($Bytes);
         $Bytes = number_format($Bytes, 0, "", ",") . ' B';
         if ($BytesH == $Bytes) {
             $BytesH = "";
         } else {
             $BytesH = '(' . $BytesH . ')';
         }
         $text = _("File Size");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>{$Bytes} {$BytesH}</td></tr>\n";
         $text = _("SHA1 Checksum");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_sha1'] . "</td></tr>\n";
         $text = _("MD5 Checksum");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_md5'] . "</td></tr>\n";
         $text = _("Repository ID");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_sha1'] . "." . $R['pfile_md5'] . "." . $R['pfile_size'] . "</td></tr>\n";
         $text = _("Pfile ID");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_fk'] . "</td></tr>\n";
         $V .= "</table>\n";
     }
     return $V;
 }
Пример #5
0
 /**
  * \brief Database metrics
  * \returns html table containing metrics
  */
 function DatabaseMetrics()
 {
     $V = "<table border=1>\n";
     $text = _("Metric");
     $text1 = _("Total");
     $V .= "<tr><th>{$text}</th><th>{$text1}</th></tr>\n";
     /* Database size */
     $sql = "SELECT pg_database_size('fossology') as val;";
     $row = $this->dbManager->getSingleRow($sql, array(), __METHOD__ . "get_Size");
     $Size = HumanSize($row['val']);
     $text = _("FOSSology database size");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'> {$Size} </td></tr>\n";
     /**** Version ****/
     $text = _("Postgresql version");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'> {$this->pgVersion[server]} </td></tr>\n";
     /**** Query stats ****/
     // count current queries
     $sql = "SELECT count(*) AS val FROM pg_stat_activity";
     $row = $this->dbManager->getSingleRow($sql, array(), __METHOD__ . "get_connection_count");
     $connection_count = $row['val'];
     /**** Active connection count ****/
     $current_query = strcmp($this->pgVersion['server'], "9.2") >= 0 ? "state" : "current_query";
     $text = _("Active database connections");
     $V .= "<tr><td>{$text}</td>";
     $V .= "<td align='right'>" . number_format($connection_count, 0, "", ",") . "</td></tr>\n";
     $V .= "</table>\n";
     return $V;
 }
Пример #6
0
 /**
  * \brief Display the info data associated with the file.
  */
 function ShowView($Upload, $Item, $ShowMenu = 0)
 {
     $V = "";
     if (empty($Upload) || empty($Item)) {
         return;
     }
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     /**********************************
        List File Info
        **********************************/
     if ($Page == 0) {
         $text = _("Repository Locator");
         $V .= "<H2>{$text}</H2>\n";
         $sql = "SELECT * FROM uploadtree\n        INNER JOIN pfile ON uploadtree_pk = \$1\n        AND pfile_fk = pfile_pk\n        LIMIT 1;";
         $R = $this->dbManager->getSingleRow($sql, array($Item), __METHOD__ . "GetFileDescribingRow");
         $V .= "<table border=1>\n";
         $text = _("Attribute");
         $text1 = _("Value");
         $V .= "<tr><th>{$text}</th><th>{$text1}</th></tr>\n";
         $Bytes = $R['pfile_size'];
         $BytesH = HumanSize($Bytes);
         $Bytes = number_format($Bytes, 0, "", ",") . ' B';
         if ($BytesH == $Bytes) {
             $BytesH = "";
         } else {
             $BytesH = '(' . $BytesH . ')';
         }
         $text = _("File Size");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>{$Bytes} {$BytesH}</td></tr>\n";
         $text = _("SHA1 Checksum");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_sha1'] . "</td></tr>\n";
         $text = _("MD5 Checksum");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_md5'] . "</td></tr>\n";
         $text = _("Repository ID");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_sha1'] . "." . $R['pfile_md5'] . "." . $R['pfile_size'] . "</td></tr>\n";
         $text = _("Pfile ID");
         $V .= "<tr><td align='center'>{$text}</td><td align='right'>" . $R['pfile_fk'] . "</td></tr>\n";
         $V .= "</table>\n";
     }
     return $V;
 }
Пример #7
0
                    <?php 
$sql = "SELECT id, url, text, upload_date, ext, size FROM db_file ORDER BY id DESC";
$result = $conn->query($sql);
$row["ext"] = "attach_file";
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $date = date_create($row["upload_date"]);
        if ($row["ext"] == "url") {
            $short = explode('/', $row["url"]);
            echo "<tr><td> <i class=\"material-icons grey-text\">change_history</i>  </td><td><a class=\"truncate\" href=\"" . $row["url"] . "\" target=\"_blank\">" . $short[2] . "/.../" . substr($row["url"], -35) . "</a></td><td></td><td>" . date_format($date, 'Y-m-d H:i') . "</td><td><a class=\"waves-effect waves-light red circle lighten-3 chip\" href=\"?del=" . $row["id"] . "\"><i class=\"material-icons circleBase\">delete</i></a></td></tr>";
        } else {
            if ($row["ext"] == "") {
                $row["ext"] = "attach_file";
            }
            echo "<tr><td> <i class=\"material-icons grey-text\">" . $row["ext"] . "</i>  </td><td><a href=\"uploads/" . $row["url"] . "\" target=\"_blank\">" . $row["text"] . "</a></td><td>" . HumanSize($row["size"]) . "</td><td>" . date_format($date, 'Y-m-d H:i') . "</td><td><a class=\"waves-effect waves-light red circle lighten-3 chip\" href=\"?del=" . $row["id"] . "\"><i class=\"material-icons circleBase\">delete</i></a></td></tr>";
        }
    }
}
?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
        <footer class="page-footer teal lighten-2">
          <div class="container">
            <div class="row">
              <div class="col l6 s12">
                <h5 class="white-text">About</h5>
Пример #8
0
    }
    // no automatic reduction, use raw phpmfs
    if ($p['mfs'] > $phpmfs) {
        $p['mfs'] = $phpmfs;
    }
    // automatic reduction control above might have made mfs higher than hard limit
}
$core->template->assign("MFS", $p['mfs']);
// Mup/Multiple
if (!$p['isMup']) {
    if (!$hasMup) {
        $core->template->assign("_mup");
    }
    $core->template->assign("_mup_field");
} else {
    $core->template->assign("maxsize", HumanSize($p['mfs']));
    $core->template->assign("_mup");
    $core->template->assign("_nmup");
}
// Validators on AutoForm fields
foreach ($p['validators'] as $tag => $fields) {
    $core->template->assign("af_" . $tag, implode(",", $fields));
}
$core->template->assign("af_datepattern", $core->intlControl->getDatePreg());
// if we had CKEDITOR being loaded, add ckeditor on the javascript links:
if (strpos($p['endScript'], 'CKEDITOR.') !== false) {
    # some field loaded CKEDITOR, so add it
    $core->addLink("ckfinder/ckfinder.js", true);
    $core->addLink("ckeditor/ckeditor.js", true);
}
// if we had a calendar, add js