Beispiel #1
0
 public static function get_Size($pdo_connection, $catalog_id)
 {
     $db_name = FileConfig::get_Value('db_name', $catalog_id);
     switch (CDB::getDriverName()) {
         case 'mysql':
             // Return N/A for MySQL server prior version 5 (no information_schemas)
             if (version_compare(CDB::getServerVersion(), '5.0.0') >= 0) {
                 // Prepare SQL statment
                 $statment = array('table' => 'information_schema.TABLES', 'fields' => array("table_schema AS 'database', (sum( data_length + index_length) / 1024 / 1024 ) AS 'dbsize'"), 'where' => array("table_schema = '{$db_name}'"), 'groupby' => 'table_schema');
                 $result = CDBUtils::runQuery(CDBQuery::get_Select($statment, $pdo_connection), $pdo_connection);
                 $db_size = $result->fetch();
                 $db_size = $db_size['dbsize'] * 1024 * 1024;
                 return CUtils::Get_Human_Size($db_size);
             } else {
                 echo 'Not supported (' . CDB::getServerVersion() . ') <br />';
             }
             break;
         case 'pgsql':
             $statment = "SELECT pg_database_size('{$db_name}') AS dbsize";
             $result = CDBUtils::runQuery($statment, $pdo_connection);
             $db_size = $result->fetch();
             return CUtils::Get_Human_Size($db_size['dbsize']);
             break;
         case 'sqlite':
             $db_size = filesize(FileConfig::get_Value('db_name', $catalog_id));
             return CUtils::Get_Human_Size($db_size);
             break;
     }
 }
Beispiel #2
0
 public static function getDiskUsage($pdo)
 {
     $fields = array('SUM(Media.VolBytes) as bytes_size');
     $statment = array('table' => 'Media', 'fields' => $fields);
     // Run SQL query
     $result = CDBUtils::runQuery(CDBQuery::get_Select($statment), $pdo);
     $result = $result->fetch();
     return $result['bytes_size'];
 }
Beispiel #3
0
 protected static function count($pdo, $tablename, $filter = null)
 {
     $fields = array('COUNT(*) as row_count');
     // Prepare and execute query
     $statment = CDBQuery::get_Select(array('table' => $tablename, 'fields' => $fields, $filter));
     $result = CDBUtils::runQuery($statment, $pdo);
     $result = $result->fetch();
     return $result['row_count'];
 }
Beispiel #4
0
 public static function count($pdo)
 {
     $fields = array('COUNT(DISTINCT FileSet) as filesets_count');
     $table = 'FileSet';
     // Prepare and execute query
     $statment = CDBQuery::get_Select(array('table' => $table, 'fields' => $fields));
     $result = CDBUtils::runQuery($statment, $pdo);
     $result = $result->fetch();
     return $result['filesets_count'];
 }
Beispiel #5
0
 public static function getPools($pdo)
 {
     $pools = null;
     $table = 'Pool';
     $where = null;
     if (FileConfig::get_Value('hide_empty_pools')) {
         $where[] = "{$table}.NumVols > 0";
     }
     $fields = array('poolid', 'name', 'numvols');
     $result = CDBUtils::runQuery(CDBQuery::get_Select(array('table' => $table, 'fields' => $fields, 'where' => $where)), $pdo);
     foreach ($result->fetchAll() as $pool) {
         $pools[] = $pool;
     }
     return $pools;
 }
Beispiel #6
0
 public static function getClientInfos($pdo, $client_id)
 {
     $client = array();
     $fields = array('name', 'uname');
     $where = array("clientid = {$client_id}");
     $statment = CDBQuery::get_Select(array('table' => 'Client', 'fields' => $fields, 'where' => $where));
     $result = CDBUtils::runQuery($statment, $pdo);
     foreach ($result->fetchAll() as $client) {
         $uname = explode(' ', $client['uname']);
         $client['version'] = $uname[0];
         $uname = explode(',', $uname[2]);
         $temp = explode('-', $uname[0]);
         $client['arch'] = $temp[0];
         $client['os'] = $uname[1];
     }
     return $client;
 }
Beispiel #7
0
    // Last used volumes widget
    // ==============================================================
    $last_volumes = array();
    // Building SQL statment
    $where = array();
    $tmp = "(Media.Volstatus != 'Disabled') ";
    switch (CDB::getDriverName()) {
        case 'mysql':
        case 'pgsql':
            $tmp .= "AND (Media.LastWritten IS NOT NULL)";
            break;
        case 'sqlite':
            $tmp .= "AND (Media.Lastwritten != 0)";
            break;
    }
    $where[] = $tmp;
    $statment = array('table' => 'Media', 'fields' => array('Media.MediaId', 'Media.Volumename', 'Media.Lastwritten', 'Media.VolStatus', 'Media.VolJobs', 'Pool.Name AS poolname'), 'join' => array('table' => 'Pool', 'condition' => 'Media.PoolId = Pool.poolid'), 'where' => $where, 'orderby' => 'Media.Lastwritten DESC', 'limit' => '10');
    // Run the query
    $result = CDBUtils::runQuery(CDBQuery::get_Select($statment), $dbSql->db_link);
    foreach ($result as $volume) {
        $last_volumes[] = $volume;
    }
    $view->assign('volumes_list', $last_volumes);
} catch (Exception $e) {
    CErrorHandler::displayError($e);
}
// Set page name
$current_page = 'Dashboard';
$view->assign('page_name', $current_page);
// Render template
$view->render('index.tpl');
Beispiel #8
0
 public static function get_Jobs_List($pdo, $client_id = null)
 {
     $jobs = array();
     $fields = array('Name');
     $where = null;
     // Prepare and execute query
     if (!is_null($client_id)) {
         $where[] = "clientid = '{$client_id}'";
     }
     $statment = array('table' => 'Job', 'fields' => $fields, 'groupby' => 'Name', 'orderby' => 'Name', 'where' => $where);
     $result = CDBUtils::runQuery(CDBQuery::get_Select($statment), $pdo);
     foreach ($result->fetchAll() as $job) {
         $jobs[] = $job['name'];
     }
     return $jobs;
 }