Example #1
0
        $this->name = $n;
        $this->data_size = $d;
        $this->index_size = $i;
        $this->total_size = $t;
        $this->rows = $r;
        $this->size_per_row = $s;
    }
    function __destruct()
    {
    }
}
$db_name = parse_config($config, "<db_name>");
db_init();
admin_page_head("BOINC Database Info");
// if you have other db's just add more get_db_info lines
$db_rec = get_db_info($db_name);
// show_db_info($db_name, $db_rec);
sort_db_info($db_name, $db_rec);
admin_page_tail();
// returns formatted data size
function size_format($size)
{
    $retval = 0;
    $KB = 1024;
    $MB = 1024 * 1024;
    $GB = 1024 * 1024 * 1024;
    $TB = 1024 * 1024 * 1024 * 1024;
    if ($size < $KB) {
        $retval = $size;
    } elseif ($size > $KB && $size < $MB) {
        $retval = sprintf("%.0fK", $size / $KB);
Example #2
0
/**
 * Attempts to insert a course into the moodle database
 *
 * @param type $course
 * @return string
 */
function up_insert_course($course)
{
    global $DB;
    $courserequestnumber = $course->idnumber;
    $category = $course->category;
    $dbinfo = get_db_info();
    $oc = new stdClass();
    try {
        $oc = oci_connect($dbinfo->username, $dbinfo->password, $dbinfo->db);
    } catch (exception $e) {
        print $e->getMessage();
    }
    // Check if the course exists
    if (up_course_exists($courserequestnumber, $category)) {
        add_to_log('1', 'course', 'error', '', "Course already exists: BannerID: {$courserequestnumber}", '', '4');
        // Mark course as added in banner
        $totalrows = 0;
        $query = "INSERT INTO UP_MOODLE.TBL_UPM_COURSE_SYNC VALUES ('{$courserequestnumber}','{$course->termcode}','Y')";
        $sql = oci_parse($oc, $query);
        oci_execute($sql);
        $results = array();
        $rows = oci_fetch_all($sql, $results, 0, $totalrows, OCI_FETCHSTATEMENT_BY_ROW);
        if ($rows = false) {
            print 'Insert to TBL_UPM_COURSE_SYNC failed. Sync may be broken.';
            exit;
        }
        return COURSE_ALREADY_EXISTS;
    } else {
        if ($newcourseid = $DB->insert_record('course', $course)) {
            if (UP_DEBUG) {
                print "New Course ID is: " . $newcourseid . "<br />\n";
            }
            //get the newly inserted course so we can add the default blocks
            $newMoodleCourse = $DB->get_record('course', array('id' => $newcourseid));
            $data = $course;
            $course = course_get_format($newcourseid)->get_course();
            // Setup the blocks
            blocks_add_default_course_blocks($newMoodleCourse);
            //set section information and insert into the section database
            $section = new stdClass();
            $section->course = $newcourseid;
            // Create a default section.
            $section->section = 0;
            $section->summaryformat = FORMAT_HTML;
            try {
                $DB->insert_record('course_sections', $section);
            } catch (coding_exception $e) {
                print $e->getMessage();
            }
            fix_course_sortorder();
            up_add_enrol_plugin('manual', true, $course, $data);
            // Mark course as added in banner
            $totalrows = 0;
            $query = "INSERT INTO UP_MOODLE.TBL_UPM_COURSE_SYNC VALUES ('{$courserequestnumber}','{$data->termcode}','Y')";
            $sql = oci_parse($oc, $query);
            oci_execute($sql);
            $results = array();
            $rows = oci_fetch_all($sql, $results, 0, $totalrows, OCI_FETCHSTATEMENT_BY_ROW);
            if ($rows = false) {
                print 'Insert to TBL_UPM_COURSE_SYNC failed. Sync may be broken.';
                exit;
            }
            $event = \core\event\course_created::create(array('objectid' => $course->id, 'context' => context_course::instance($course->id), 'other' => array('shortname' => $course->shortname, 'fullname' => $course->fullname)));
            $event->trigger();
            return COURSE_CREATION_SUCCEEDED;
        } else {
            add_to_log('1', 'course', 'error', '', "Creating: {$shortname} (BANID {$courserequestnumber})", '', '4');
            return COURSE_CREATION_FAILED;
        }
    }
    // end of else on if ( $newcourseid = $DB->insert_record('course', $form) )
}
Example #3
0
						<p><?php 
        echo translate('confirmintro');
        ?>
</p>
						<p><?php 
        echo translate('installdetails');
        ?>
</p>
						<table border="0">
							<tr>
								<td><?php 
        echo translate('dbtype');
        ?>
</td>
								<td><?php 
        echo get_db_info(get_cookie_data('dbtype'));
        ?>
</td>
							</tr>
							<tr>
								<td><?php 
        echo translate('dbhost');
        ?>
</td>
								<td><?php 
        echo get_cookie_data('dbhost');
        ?>
</td>
							</tr>
							<tr>
								<td><?php 
Example #4
0
    <script src="../js/treeview/jquery.treeview.js" type="text/javascript"></script>

<?php 
$hostname = $_POST["host"];
$port = $_POST["port"];
$username = $_POST["username"];
$password = $_POST["password"];
function get_db_info($hostname, $port, $username, $password, &$output)
{
    $cmd = "./python/get_db_info.py '{$hostname}' '{$port}' '{$username}' '{$password}'";
    exec($cmd, $output, $ret);
    return $ret;
}
$output = array();
//data format: dbnamecollection1collection2dbname2collection1collection2...
$ret = get_db_info($hostname, $port, $username, $password, $output);
if ($ret != 0) {
    echo "<font color='red'>错误:数据库连接错误,请确保输入的数据正确!</font><a href='../index.php'>重新输入</a>";
    exit($ret);
}
file_put_contents("../data/login.txt", "{$hostname}{$port}{$username}\n", FILE_APPEND);
// $output = "db1table1table2table3db2table1table2";
?>

    <script>
        <?php 
echo "var _hostname = '{$hostname}';\n";
echo "var _port = '{$port}';\n";
echo "var _user = '******';\n";
echo "var _password= '******';\n";
?>