Beispiel #1
0
/**
 * Returns a string containing a link to the user documentation for the current
 * page. Also contains an icon by default. Shown to teachers and admin only.
 *
 * @param string $text The text to be displayed for the link
 * @param string $iconpath The path to the icon to be displayed
 */
function page_doc_link($text = '', $iconpath = '')
{
    global $CFG, $PAGE;
    if (empty($CFG->docroot) || empty($CFG->rolesactive)) {
        return '';
    }
    if (!has_capability('moodle/site:doclinks', $PAGE->context)) {
        return '';
    }
    $path = $PAGE->docspath;
    if (!$path) {
        return '';
    }
    return doc_link($path, $text, $iconpath);
}
Beispiel #2
0
/**
 * Returns a string containing a link to the user documentation for the current
 * page. Also contains an icon by default. Shown to teachers and admin only.
 *
 * @param string $text      The text to be displayed for the link
 * @param string $iconpath  The path to the icon to be displayed
 */
function page_doc_link($text = '', $iconpath = '')
{
    global $ME, $COURSE, $CFG;
    if (empty($CFG->docroot) or empty($CFG->rolesactive)) {
        return '';
    }
    if (empty($COURSE->id)) {
        $context = get_context_instance(CONTEXT_SYSTEM);
    } else {
        $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
    }
    if (!has_capability('moodle/site:doclinks', $context)) {
        return '';
    }
    if (empty($CFG->pagepath)) {
        $CFG->pagepath = $ME;
    }
    $path = str_replace($CFG->httpswwwroot . '/', '', $CFG->pagepath);
    // Because the page could be HTTPSPAGEREQUIRED
    $path = str_replace('.php', '', $path);
    if (empty($path)) {
        // Not for home page
        return '';
    }
    return doc_link($path, $text, $iconpath);
}
Beispiel #3
0
/** Print table interior for fields editing
* @param array
* @param array
* @param string TABLE or PROCEDURE
* @param array returned by referencable_primary()
* @param bool display comments column
* @return null
*/
function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array(), $comments = false)
{
    global $connection, $inout;
    $fields = array_values($fields);
    ?>
<thead><tr class="wrap">
<?php 
    if ($type == "PROCEDURE") {
        ?>
<td>&nbsp;<?php 
    }
    ?>
<th><?php 
    echo $type == "TABLE" ? lang('Column name') : lang('Parameter name');
    ?>
<td><?php 
    echo lang('Type');
    ?>
<textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur(this);"></textarea>
<td><?php 
    echo lang('Length');
    ?>
<td><?php 
    echo lang('Options');
    if ($type == "TABLE") {
        ?>
<td>NULL
<td><input type="radio" name="auto_increment_col" value=""><acronym title="<?php 
        echo lang('Auto Increment');
        ?>
">AI</acronym><?php 
        echo doc_link(array('sql' => "example-auto-increment.html", 'sqlite' => "autoinc.html", 'pgsql' => "datatype.html#DATATYPE-SERIAL", 'mssql' => "ms186775.aspx"));
        ?>
<td><?php 
        echo lang('Default value');
        echo support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : "";
    }
    ?>
<td><?php 
    echo "<input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>";
    ?>
<script type="text/javascript">row_count = <?php 
    echo count($fields);
    ?>
;</script>
</thead>
<tbody onkeydown="return editingKeydown(event);">
<?php 
    foreach ($fields as $i => $field) {
        $i++;
        $orig = $field[$_POST ? "orig" : "field"];
        $display = (isset($_POST["add"][$i - 1]) || isset($field["field"]) && !$_POST["drop_col"][$i]) && (support("drop_col") || $orig == "");
        ?>
<tr<?php 
        echo $display ? "" : " style='display: none;'";
        ?>
>
<?php 
        echo $type == "PROCEDURE" ? "<td>" . html_select("fields[{$i}][inout]", explode("|", $inout), $field["inout"]) : "";
        ?>
<th><?php 
        if ($display) {
            ?>
<input name="fields[<?php 
            echo $i;
            ?>
][field]" value="<?php 
            echo h($field["field"]);
            ?>
" onchange="editingNameChange(this);<?php 
            echo $field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow(this);" onkeyup="if (this.value) editingAddRow(this);';
            ?>
" maxlength="64" autocapitalize="off"><?php 
        }
        ?>
<input type="hidden" name="fields[<?php 
        echo $i;
        ?>
][orig]" value="<?php 
        echo h($orig);
        ?>
">
<?php 
        edit_type("fields[{$i}]", $field, $collations, $foreign_keys);
        if ($type == "TABLE") {
            ?>
<td><?php 
            echo checkbox("fields[{$i}][null]", 1, $field["null"], "", "", "block");
            ?>
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php 
            echo $i;
            ?>
"<?php 
            if ($field["auto_increment"]) {
                ?>
 checked<?php 
            }
            ?>
 onclick="var field = this.form['fields[' + this.value + '][field]']; if (!field.value) { field.value = 'id'; field.onchange(); }"></label><td><?php 
            echo checkbox("fields[{$i}][has_default]", 1, $field["has_default"]);
            ?>
<input name="fields[<?php 
            echo $i;
            ?>
][default]" value="<?php 
            echo h($field["default"]);
            ?>
" onkeyup="keyupChange.call(this);" onchange="this.previousSibling.checked = true;">
<?php 
            echo support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[{$i}][comment]' value='" . h($field["comment"]) . "' maxlength='" . ($connection->server_info >= 5.5 ? 1024 : 255) . "'>" : "";
        }
        echo "<td>";
        echo support("move_col") ? "<input type='image' class='icon' name='add[{$i}]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, 1);'>&nbsp;" . "<input type='image' class='icon' name='up[{$i}]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>&nbsp;" . "<input type='image' class='icon' name='down[{$i}]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>&nbsp;" : "";
        echo $orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[{$i}]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'fields\$1[field]');\">" : "";
        echo "\n";
    }
}
Beispiel #4
0
    $row["collation"] = db_collation(DB, $collations);
} elseif ($jush == "sql") {
    // propose database name with limited privileges
    foreach (get_vals("SHOW GRANTS") as $grant) {
        if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $grant, $match) && $match[1]) {
            $name = stripcslashes(idf_unescape("`{$match['2']}`"));
            break;
        }
    }
}
?>

<form action="" method="post">
<p>
<?php 
echo ($_POST["add_x"] || strpos($name, "\n") ? '<textarea id="name" name="name" rows="10" cols="40">' . h($name) . '</textarea><br>' : '<input name="name" id="name" value="' . h($name) . '" maxlength="64" autocapitalize="off">') . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $row["collation"]) . doc_link(array('sql' => "charset-charsets.html", 'mssql' => "ms187963.aspx")) : "");
?>
<script type='text/javascript'>focus(document.getElementById('name'));</script>
<input type="submit" value="<?php 
echo lang('Save');
?>
">
<?php 
if (DB != "") {
    echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
    echo "<input type='image' class='icon' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
}
?>
<input type="hidden" name="token" value="<?php 
echo $token;
    }
    queries_redirect(ME . "processlist=", lang('%d process(es) have been killed.', $killed), $killed || !$_POST["kill"]);
}
page_header(lang('Process list'), $error);
?>

<form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" ondblclick="tableClick(event, true);" class="nowrap checkable">
<?php 
// HTML valid because there is always at least one process
$i = -1;
foreach (process_list() as $i => $row) {
    if (!$i) {
        echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "");
        foreach ($row as $key => $val) {
            echo "<th>{$key}" . doc_link(array('sql' => "show-processlist.html#processlist_" . strtolower($key), 'pgsql' => "monitoring-stats.html#PG-STAT-ACTIVITY-VIEW", 'oracle' => "../b14237/dynviews_2088.htm"));
        }
        echo "</thead>\n";
    }
    echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row[$jush == "sql" ? "Id" : "pid"], 0) : "");
    foreach ($row as $key => $val) {
        echo "<td>" . ($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "" || $jush == "pgsql" && $key == "current_query" && $val != "<IDLE>" || $jush == "oracle" && $key == "sql_text" && $val != "" ? "<code class='jush-{$jush}'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Clone') . '</a>' : nbsp($val));
    }
    echo "\n";
}
?>
</table>
<script type='text/javascript'>tableCheck();</script>
<p>
<?php 
if (support("kill")) {
/**
 * This function will print one beautiful table with all the environmental
 * configuration and how it suits Moodle needs.
 * @param boolean final result of the check (true/false)
 * @param array environment_results array of results gathered
 */
function print_moodle_environment($result, $environment_results)
{
    /// Get some strings
    $strname = get_string('name');
    $strinfo = get_string('info');
    $strreport = get_string('report');
    $strstatus = get_string('status');
    $strok = get_string('ok');
    $strerror = get_string('error');
    $strcheck = get_string('check');
    $strbypassed = get_string('bypassed');
    $strrestricted = get_string('restricted');
    $strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');
    /// Table headers
    $servertable = new stdClass();
    //table for server checks
    $servertable->head = array($strname, $strinfo, $strreport, $strstatus);
    $servertable->align = array('center', 'center', 'left', 'center');
    $servertable->wrap = array('nowrap', '', '', 'nowrap');
    $servertable->size = array('10', 10, '100%', '10');
    $servertable->width = '90%';
    $servertable->class = 'environmenttable generaltable';
    $serverdata = array('ok' => array(), 'warn' => array(), 'error' => array());
    $othertable = new stdClass();
    //table for custom checks
    $othertable->head = array($strinfo, $strreport, $strstatus);
    $othertable->align = array('center', 'left', 'center');
    $othertable->wrap = array('', '', 'nowrap');
    $othertable->size = array(10, '100%', '10');
    $othertable->width = '90%';
    $othertable->class = 'environmenttable generaltable';
    $otherdata = array('ok' => array(), 'warn' => array(), 'error' => array());
    /// Iterate over each environment_result
    $continue = true;
    foreach ($environment_results as $environment_result) {
        $errorline = false;
        $warningline = false;
        if ($continue) {
            $type = $environment_result->getPart();
            $info = $environment_result->getInfo();
            $status = $environment_result->getStatus();
            $error_code = $environment_result->getErrorCode();
            /// Process Report field
            $rec = new stdClass();
            /// Something has gone wrong at parsing time
            if ($error_code) {
                $stringtouse = 'environmentxmlerror';
                $rec->error_code = $error_code;
                $status = $strerror;
                $errorline = true;
                $continue = false;
            }
            if ($continue) {
                /// We are comparing versions
                if ($rec->needed = $environment_result->getNeededVersion()) {
                    $rec->current = $environment_result->getCurrentVersion();
                    if ($environment_result->getLevel() == 'required') {
                        $stringtouse = 'environmentrequireversion';
                    } else {
                        $stringtouse = 'environmentrecommendversion';
                    }
                    /// We are checking installed & enabled things
                } else {
                    if ($environment_result->getPart() == 'custom_check') {
                        if ($environment_result->getLevel() == 'required') {
                            $stringtouse = 'environmentrequirecustomcheck';
                        } else {
                            $stringtouse = 'environmentrecommendcustomcheck';
                        }
                    } else {
                        if ($environment_result->getLevel() == 'required') {
                            $stringtouse = 'environmentrequireinstall';
                        } else {
                            $stringtouse = 'environmentrecommendinstall';
                        }
                    }
                }
                /// Calculate the status value
                if ($environment_result->getBypassStr() != '') {
                    //Handle bypassed result (warning)
                    $status = $strbypassed;
                    $warningline = true;
                } else {
                    if ($environment_result->getRestrictStr() != '') {
                        //Handle restricted result (error)
                        $status = $strrestricted;
                        $errorline = true;
                    } else {
                        if ($status) {
                            //Handle ok result (ok)
                            $status = $strok;
                        } else {
                            if ($environment_result->getLevel() == 'optional') {
                                //Handle check result (warning)
                                $status = $strcheck;
                                $warningline = true;
                            } else {
                                //Handle error result (error)
                                $status = $strcheck;
                                $errorline = true;
                            }
                        }
                    }
                }
            }
            /// Build the text
            $linkparts = array();
            $linkparts[] = 'admin/environment';
            $linkparts[] = $type;
            if (!empty($info)) {
                $linkparts[] = $info;
            }
            $report = doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
            /// Format error or warning line
            if ($errorline || $warningline) {
                $messagetype = $errorline ? 'error' : 'warn';
            } else {
                $messagetype = 'ok';
            }
            $status = '<span class="' . $messagetype . '">' . $status . '</span>';
            /// Here we'll store all the feedback found
            $feedbacktext = '';
            ///Append  the feedback if there is some
            $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
            ///Append the bypass if there is some
            $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
            ///Append the restrict if there is some
            $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
            $report .= $feedbacktext;
            /// Add the row to the table
            if ($environment_result->getPart() == 'custom_check') {
                $otherdata[$messagetype][] = array($info, $report, $status);
            } else {
                $serverdata[$messagetype][] = array($type, $info, $report, $status);
            }
        }
    }
    //put errors first in
    $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
    $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
    /// Print table
    print_heading(get_string('serverchecks', 'admin'));
    print_table($servertable);
    if (count($othertable->data)) {
        print_heading(get_string('customcheck', 'admin'));
        print_table($othertable);
    }
    /// Finally, if any error has happened, print the summary box
    if (!$result) {
        print_simple_box($strenvironmenterrortodo, 'center', '', '', '', 'environmentbox errorbox');
    }
}
echo h($row["pass"]);
?>
">
<?php 
if (!$row["hashed"]) {
    ?>
<script type="text/javascript">typePassword(document.getElementById('pass'));</script><?php 
}
echo adminer_checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);");
?>
</table>

<?php 
//! MAX_* limits, REQUIRE
echo "<table cellspacing='0'>\n";
echo "<thead><tr><th colspan='2'>" . lang('Privileges') . doc_link(array('sql' => "grant.html#priv_level"));
$i = 0;
foreach ($grants as $object => $grant) {
    echo '<th>' . ($object != "*.*" ? "<input name='objects[{$i}]' value='" . h($object) . "' size='10' autocapitalize='off'>" : "<input type='hidden' name='objects[{$i}]' value='*.*' size='10'>*.*");
    //! separate db, table, columns, PROCEDURE|FUNCTION, routine
    $i++;
}
echo "</thead>\n";
foreach (array("" => "", "Server Admin" => lang('Server'), "Databases" => lang('Database'), "Tables" => lang('Table'), "Columns" => lang('Column'), "Procedures" => lang('Routine')) as $context => $desc) {
    foreach ((array) $privileges[$context] as $privilege => $comment) {
        echo "<tr" . odd() . "><td" . ($desc ? ">{$desc}<td" : " colspan='2'") . ' lang="en" title="' . h($comment) . '">' . h($privilege);
        $i = 0;
        foreach ($grants as $object => $grant) {
            $name = "'grants[{$i}][" . h(strtoupper($privilege)) . "]'";
            $value = $grant[strtoupper($privilege)];
            if ($context == "Server Admin" && $object != (isset($grants["*.*"]) ? "*.*" : ".*")) {
Beispiel #8
0
function struct_link($sfml_struct, $doc_struct = null)
{
    doc_link("struct", $sfml_struct, $doc_struct);
}
Beispiel #9
0
     echo "<input type='search' name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
     echo "</div></fieldset>\n";
     if ($_POST["search"] && $_POST["query"] != "") {
         search_tables();
     }
 }
 echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
 echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\\[/);">';
 $doc_link = doc_link(array('sql' => 'show-table-status.html'));
 echo '<th>' . lang('Table');
 echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
 echo '<td>' . lang('Collation') . doc_link(array('sql' => 'charset-mysql.html'));
 echo '<td>' . lang('Data Length') . $doc_link;
 echo '<td>' . lang('Index Length') . $doc_link;
 echo '<td>' . lang('Data Free') . $doc_link;
 echo '<td>' . lang('Auto Increment') . doc_link(array('sql' => 'example-auto-increment.html'));
 echo '<td>' . lang('Rows') . $doc_link;
 echo support("comment") ? '<td>' . lang('Comment') . $doc_link : '';
 echo "</thead>\n";
 $tables = 0;
 foreach ($tables_list as $name => $type) {
     $view = $type !== null && !preg_match('~table~i', $type);
     echo '<tr' . odd() . '><td>' . checkbox($view ? "views[]" : "tables[]", $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
     echo '<th>' . (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
     if ($view) {
         echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . (preg_match('~materialized~i', $type) ? lang('Materialized View') : lang('View')) . '</a>';
         echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>';
     } else {
         foreach (array("Engine" => array(), "Collation" => array(), "Data_length" => array("create", lang('Alter table')), "Index_length" => array("indexes", lang('Alter indexes')), "Data_free" => array("edit", lang('New item')), "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), "Rows" => array("select", lang('Select data'))) as $key => $link) {
             $id = " id='{$key}-" . h($name) . "'";
             echo $link ? "<td align='right'>" . (support("table") || $key == "Rows" || support("indexes") && $key != "Data_length" ? "<a href='" . h(ME . "{$link['0']}=") . urlencode($name) . "'{$id} title='{$link['1']}'>?</a>" : "<span{$id}>?</span>") : "<td id='{$key}-" . h($name) . "'>&nbsp;";
Beispiel #10
0
    }
    ?>
</table>
<p>
<?php 
    echo lang('ON DELETE');
    ?>
: <?php 
    echo html_select("on_delete", array(-1 => "") + explode("|", $on_actions), $row["on_delete"]);
    ?>
 <?php 
    echo lang('ON UPDATE');
    ?>
: <?php 
    echo html_select("on_update", array(-1 => "") + explode("|", $on_actions), $row["on_update"]);
    echo doc_link(array('sql' => "innodb-foreign-key-constraints.html", 'pgsql' => "sql-createtable.html#SQL-CREATETABLE-REFERENCES", 'mssql' => "ms174979.aspx", 'oracle' => "clauses002.htm#sthref2903"));
    ?>
<p>
<input type="submit" value="<?php 
    echo lang('Save');
    ?>
">
<noscript><p><input type="submit" name="add" value="<?php 
    echo lang('Add column');
    ?>
"></noscript>
<?php 
}
if ($name != "") {
    ?>
<input type="submit" name="drop" value="<?php