Esempio n. 1
0
function index($params)
{
    global $content_schema;
    $content_schema['lang']['enum'] = list_languages();
    $data = array('schema' => $content_schema);
    $db = connect_database();
    //
    if (isset($params['title'])) {
        if ($params['id'] == 'new') {
            $params['published'] = date('Y-m-d H:i:s');
            $db->insert('content', $params);
        } else {
            $db->update('content', $params);
        }
        flash_message('Content is saved', 'success');
        redirect('dashboard');
    } else {
        $per_page = 5;
        $page = 1;
        if (isset($params[0])) {
            $page = $params[0];
        }
        $data['page'] = $page;
        $data['news'] = $db->query('SELECT id, published, slug, lang, title FROM content ORDER BY published DESC LIMIT ' . $per_page * ($page - 1) . ', ' . $per_page);
        $pages = row_array($db->query('SELECT COUNT(*) FROM content'));
        $data['pages'] = ceil($pages[0] / $per_page);
    }
    //
    $data['html_head'] = array('title' => 'Content Dashboard');
    return $data;
}
Esempio n. 2
0
function database($params)
{
    /*global $table_schema;
    		write_schema('dbtable', $table_schema);*/
    $data = array();
    $db = connect_database();
    //
    if (isset($params['sql']) && is_array($params['sql'])) {
        foreach ($params['sql'] as $sql) {
            if (trim($sql) != '') {
                $db->query($sql);
            }
        }
    }
    //
    $data['import'] = @unserialize(gzinflate(file_get_contents('data/schema.db')));
    if (!$data['import']) {
        $data['import'] = array();
    }
    //print_r($file);
    //
    $tables = $db->query('SHOW tables');
    $data['tables'] = array();
    while ($table = row_array($tables)) {
        $columns = $db->query('DESCRIBE `' . $table[0] . '`');
        $tmp = array();
        $cname = '';
        while ($column = row_assoc($columns)) {
            $field = $column['Field'];
            unset($column['Field']);
            $size = explode('(', $column['Type']);
            $column['Type'] = $size[0];
            $column['Size'] = count($size) == 2 ? str_replace(')', '', $size[1]) : '';
            $tmp[$field] = $column;
        }
        $data['tables'][$table[0]] = $tmp;
    }
    $data['schema'] = load_schema('dbtable');
    //
    if (isset($params[0]) && $params[0] == 'export') {
        //	CHECK IF THERE ARE CONFLICTS
        $result = file_put_contents('data/schema.db', gzdeflate(serialize($data['tables'])));
        if ($result) {
            flash_message('Database schema is exported', 'success');
        } else {
            flash_message('No permission to write to data/schema.db', 'warning');
        }
        redirect('admin/developer', 'database');
    }
    //
    $data['html_head'] = array('title' => 'Database');
    return $data;
}
Esempio n. 3
0
function showTableStatus($db)
{
    $size = 0;
    $out = "";
    start_table();
    row1($db, 15);
    row_array(array("Name", "Engine", "Version", "Row Format", "Rows", "Avg Row Length (KB)", "Data Length (MB)", "Max Data Length (MB)", "Index Length (MB)", "Data free (MB)", "Create Time", "Update Time", "Check Time", "Create Options", "Comment"));
    _mysql_select_db($db);
    $result = _mysql_query("show table status");
    while ($row = _mysql_fetch_array($result)) {
        $size += $row["Data_length"] + $row["Index_length"];
        $engine = $row["Engine"];
        if (!$engine) {
            $engine = $row["Type"];
        }
        row_array(array($row["Name"], $engine, $row["Version"], $row["Row_format"], $row["Rows"], round($row["Avg_row_length"] / 1024, 2), round($row["Data_length"] / (1024 * 1024), 2), round($row["Max_data_length"] / (1024 * 1024), 2), round($row["Index_length"] / (1024 * 1024), 2), round($row["Data_free"] / (1024 * 1024), 2), $row["Create_time"], $row["Update_time"], $row["Check_time"], $row["Create_options"], $row["Comment"]));
    }
    $size = round($size / 1024 / 1024, 1);
    row2("Total Table Sizes (MB)", $size);
    end_table();
    echo "<BR><BR>";
}
Esempio n. 4
0
function show_cpu_list($data)
{
    page_head("CPU performance");
    echo "\n        This table shows peak CPU speed\n        (based on Whetstone benchmarks)\n        of computers participating in this project.\n        <p>\n    ";
    start_table();
    row_heading_array(array("CPU model", "Number of computers", "Avg. cores/computer", "GFLOPS/core", "GFLOPs/computer"));
    $i = 0;
    $total_nhosts = 0;
    $total_gflops = 0;
    foreach ($data->cpus as $d) {
        row_array(array($d->model, $d->nhosts, number_format($d->mean_ncores, 2), number_format($d->p_fpops / 1000000000.0, 2), number_format($d->mean_ncores * $d->p_fpops / 1000000000.0, 2)), "row{$i}");
        $total_nhosts += $d->nhosts;
        $total_gflops += $d->nhosts * $d->mean_ncores * $d->p_fpops / 1000000000.0;
        $i = 1 - $i;
    }
    row_array(array("Total", number_format($total_nhosts, 0) . " computers", "", "", number_format($total_gflops / 1000.0, 2) . " TeraFLOPS"), "row{$i}");
    end_table();
    echo "Generated " . time_str($data->time);
    page_tail();
}
 function student_position($student_id, $school_id)
 {
     $sql = "SELECT position FROM scl_result_summary WHERE student_id = {$student_id} AND {$school_id} = {$school_id} LIMIT 1";
     #dumpVar($sql);
     $row = row_array($sql);
     return $row['position'];
 }
Esempio n. 6
0
	function update($id)
	{
		// set common properties
		$data['title']='Update siswa';
		$this->load->library('form_validation');
		// set validation properties
		$this->_set_rules();
		$data['action']=('siswa/update/'.$id);
		// run validation
		if ($this->form_validation->run()=== FALSE)
		{
			$data['message']='';
			$data['siswa']=$this->siswa_model->get_by_id($id)>row_array();
			$_POST['jenis_kelamin']=strtoupper($data['siswa']['jenis_kelamin']);
			$data['siswa']['tanggal_lahir']= date('d-m-Y',strtotime($data['siswa']['tanggal_lahir']));
			// set common properties
			$data['title']='Update siswa';
			$data['message']='';
		} else {
			// save data
			$id=$this->input->post('id');
			$siswa= array('nama'=>$this->input->post('nama'),
			'alamat'=>$this->input->post('alamat'),
			'jenis_kelamin'=>$this->input->post('jenis_kelamin'),
			'tanggal_lahir'=> date('Y-m-d',strtotime($this->input->post('tanggal_lahir'))));
			$this->siswa_model->update($id,$siswa);
			$data['siswa']=$this->siswa_model->get_by_id($id)->row_array();
			// set user message
			$data['message']='update siswa success';
		}
		$data['link_back']= anchor('siswa/index/','Lihat daftar siswa',array('class'=>'back'));
		// load view
		$this->load->view('siswaEdit',$data);
	}
        echo "<p><a href=host_edit_form.php?hostid={$hostid}&detail=1>" . tra("Show details") . "</a>\n        ";
    }
    page_tail();
    exit;
}
echo "\n    <p>" . tra("Check the computers that are the same as %1 (created %2, computer ID %3):", $host->domain_name, $t, $host->id) . "\n    <p>\n";
start_table();
row_heading_array(array("", tra("name"), tra("created"), tra("computer ID")));
$i = 1;
foreach ($hosts as $host2) {
    $t = time_str($host2->create_time);
    $x = $host2->domain_name;
    if ($x == "") {
        $x = "[" . tra("no hostname") . "]";
    }
    row_array(array("<input type=checkbox name=id_{$i} value={$host2->id}>", $x, "{$t}", "{$host2->id}"));
    $i++;
}
end_table();
echo "\n    <br>\n    <script>\n        function set_all() {\n";
for ($i = 1; $i < $nhosts; $i++) {
    echo "document.host_list.id_{$i}.checked=1;\n";
}
echo "\n        }\n        function clear_all() {\n";
for ($i = 1; $i < $nhosts; $i++) {
    echo "document.host_list.id_{$i}.checked=0;\n";
}
echo "\n        }\n    </script>\n    <p><a href=javascript:set_all()>Select all</a>\n    <p><a href=javascript:clear_all()>Unselect all</a>\n    <input type=hidden name=nhosts value={$nhosts}>\n    <p><input type=submit value='" . tra("Merge hosts") . "'>\n    </form>\n";
if (!$detail) {
    echo "<p><a href=host_edit_form.php?hostid={$hostid}&detail=1>" . tra("Show details") . "</a>\n    ";
}