예제 #1
0
function op_renameent()
{
    if (!welcome_here()) {
        return;
    }
    if (!get_input_string('entname', 'current entrypoint name', $entname)) {
        return;
    }
    if (!get_input_string('newval', 'new entrypoint name', $newval)) {
        return;
    }
    if (!get_input_string('extname', 'extension name', $extname)) {
        return;
    }
    if (!get_input_int('extid', 'extension id', $extid)) {
        return;
    }
    // see if it's already in the database...
    $sqlnewval = db_escape_string($newval);
    $sql = 'select ent.*, ext.extname from alextreg_entrypoints as ent' . ' left outer join alextreg_extensions as ext' . ' on ent.extid=ext.id' . " where (entrypointname='{$sqlnewval}')";
    $query = do_dbquery($sql);
    if ($query == false) {
        return;
    }
    // error output is handled in database.php ...
    if (db_num_rows($query) > 0) {
        write_error('The new entry point is in use. Below is what a search turned up.');
        render_entrypoint_list($newval, $query);
        db_free_result($query);
        return;
    }
    // if
    db_free_result($query);
    // Just a small sanity check.
    $cookie = $_REQUEST['iamsure'];
    if (!empty($cookie) and $cookie == $_SERVER['REMOTE_ADDR']) {
        $sqlentname = db_escape_string($entname);
        $sqlauthor = db_escape_string($_SERVER['REMOTE_USER']);
        // ok, nuke it.
        $sql = "update alextreg_entrypoints set entrypointname='{$sqlnewval}'," . " lastedit=NOW(), lasteditauthor='{$sqlauthor}'" . " where entrypointname='{$sqlentname}'";
        if (do_dbupdate($sql) == 1) {
            update_papertrail("Entry point '{$entname}' renamed to '{$newval}'", $sql, $extid);
            do_showext($extname);
        }
        // if
    } else {
        $form = get_form_tag();
        $htmlnewval = htmlentities($newval, ENT_QUOTES);
        $htmlextname = htmlentities($extname, ENT_QUOTES);
        $htmlentname = htmlentities($entname, ENT_QUOTES);
        echo "About to rename an entry point named '{$htmlentname}' to '{$htmlnewval}'.<br>\n";
        echo "...if you're sure, click 'Confirm'...<br>\n";
        echo "{$form}\n";
        echo "<input type='hidden' name='iamsure' value='{$_SERVER['REMOTE_ADDR']}'>\n";
        echo "<input type='hidden' name='extid' value='{$extid}'>\n";
        echo "<input type='hidden' name='newval' value='{$htmlnewval}'>\n";
        echo "<input type='hidden' name='entname' value='{$htmlentname}'>\n";
        echo "<input type='hidden' name='extname' value='{$htmlextname}'>\n";
        echo "<input type='hidden' name='operation' value='op_renameent'>\n";
        echo "<input type='submit' name='form_submit' value='Confirm'>\n";
        echo "</form>\n";
    }
    // else
}
예제 #2
0
function find_entrypoint($wantname)
{
    $sql = 'select ent.entrypointname as entrypointname,' . ' ext.extname as extname' . ' from alextreg_entrypoints as ent' . ' left outer join alextreg_extensions as ext' . ' on ent.extid=ext.id where (1=1)';
    if (!is_authorized_vendor()) {
        $sql .= " and (ext.public=1)";
    }
    if ($wantname) {
        $sqlwantname = db_escape_string($wantname);
        $sql .= " and (ent.entrypointname='{$sqlwantname}')";
    }
    // if
    $sql .= ' order by ent.entrypointname';
    $query = do_dbquery($sql);
    if ($query == false) {
        return;
    } else {
        render_entrypoint_list($wantname, $query);
    }
    db_free_result($query);
}