Пример #1
0
function login( $uacc, $upwd ){
    $login = (array)json_decode(
        file_get_contents_curl(
            'http://apit.cedric.testapi-1.stu.edu.tw/acc/auth/uacc/'.$uacc.'/?upwd='.$upwd),true);
    # Authentication fail.
    if ( $login['status'] )
        print_response_msg(3);

    # Analyze data.
    $ou_group;
    $start_tag = "ou=";
    $close_tag = ",";
    preg_match_all("($start_tag(.*)$close_tag)siU", $login['dn'], $ou_group);

    # If login user not is student, this column value set 0.
    if ( !preg_match('/\d{2,3}/', $ou_group[1][0]) )
        $ou_group[1][0] = 0;

    # Get record data.
    $sql = "SELECT record_id FROM record WHERE account=? ";
    $record_id = sql_q( $sql, array($login['uacc']) );

    # If this account not have play record in database, insert new row to database.
    if ( !count($record_id) ) {
        $addRecord = add_record(
            $login['uacc'],
            $ou_group[1][1]
        );
        if ( $addRecord )
            $record_id = sql_q( $sql, array($login['uacc']) );
        else
            print_response_msg(5);
    }

    # Session content
    $profile = array(
        'record_id' => $record_id[0]['record_id'],
        'account'   => $login['uacc'],
        'name'      => $login['uname'],
        'dep'       => $ou_group[1][1]
    );

    # Define session
    $_SESSION[ session_id() ] = $profile;

    # Print login success message and session data.
    print_response_msg( 2, $profile );
}
Пример #2
0
function read_udmz_lines($lines)
{
    $out = array();
    $title = 'PREAMBULE';
    $curr = array();
    $legenda = get_legenda($lines[0]);
    for ($i = 1; $i < count($lines); $i++) {
        if (trim($lines[$i]) == '########') {
            if (isset($curr)) {
                arrayarray($out, explode('.', $title), $curr);
                unset($curr);
            }
            if (known_section($lines[$i + 1], $out['PREAMBULE'])) {
                $title = trim($lines[$i + 1]);
                $curr = array();
                $legenda = get_legenda($lines[$i + 2]);
            }
            $i += 2;
        } else {
            if (isset($curr)) {
                add_record($curr, $legenda, $lines[$i]);
            }
        }
    }
    return $out;
}
Пример #3
0
        $ret = delete_record($args);
        if ($ret !== true) {
            output_error($ret);
        }
        break;
    case '/add-record':
        $ret = add_record($args);
        if ($ret !== true) {
            output_error($ret);
        }
        break;
    case '/update-record':
        $original = $args['record']['original'];
        $new = $args['record']['new'];
        $args['record'] = $original;
        // output_error(print_r($args));
        $ret = delete_record($args);
        if ($ret !== true) {
            output_error($ret);
        }
        $args['record'] = $new;
        $ret = add_record($args);
        if ($ret !== true) {
            $args['record'] = $original;
            add_record($args);
            output_error($ret);
        }
        break;
    default:
        output_error('Requested method is not available.', 501);
}
Пример #4
0
            } elseif ($type === 'AAAA') {
                $content_rev = convert_ipv6addr_to_ptrrec($content);
                $zone_rev_id = get_best_matching_zone_id_from_name($content_rev);
            }
            if (isset($zone_rev_id) && $zone_rev_id != -1) {
                $zone_name = get_zone_name_from_id($zone_id);
                $fqdn_name = sprintf("%s.%s", $name, $zone_name);
                if (add_record($zone_rev_id, $content_rev, 'PTR', $fqdn_name, $ttl, $prio)) {
                    success(" <a href=\"edit.php?id=" . $zone_rev_id . "\"> " . _('The PTR-record was successfully added.') . "</a>");
                    log_info(sprintf('client_ip:%s user:%s operation:add_record record_type:PTR record:%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $content_rev, $fqdn_name, $ttl, $prio));
                }
            } elseif (isset($content_rev)) {
                error(sprintf(ERR_REVERS_ZONE_NOT_EXIST, $content_rev));
            }
        }
        if (add_record($zone_id, $name, $type, $content, $ttl, $prio)) {
            success(" <a href=\"edit.php?id=" . $zone_id . "\"> " . _('The record was successfully added.') . "</a>");
            log_info(sprintf('client_ip:%s user:%s operation:add_record record_type:%s record:%s.%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $type, $name, $zone_name, $content, $ttl, $prio));
            $name = $type = $content = $ttl = $prio = "";
        }
    }
}
/*
 Display form to add a record
*/
echo "    <h2>" . _('Add record to zone') . " <a href=\"edit.php?id=" . $zone_id . "\"> " . $zone_name . "</a></h2>\n";
if ($zone_type == "SLAVE" || $perm_content_edit == "none" || ($perm_content_edit == "own" || $perm_content_edit == "own_as_client") && $user_is_zone_owner == "0") {
    error(ERR_PERM_ADD_RECORD);
} else {
    echo "     <form method=\"post\">\n";
    echo "      <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n";
Пример #5
0
function add_record()
{
    // create add record query
    $query = "/json-api/addzonerecord?zone=" . $GLOBALS['record_zone'] . "&name=" . $GLOBALS['record_name'] . "&address=" . $GLOBALS['record_address'] . "&type=A&class=IN&ttl=" . $GLOBALS['record_TTL'];
    // process query
    if (curl_request($query)) {
        echo "RECORD_ADDED\n";
    }
}
function update_record($record_line)
{
    // create update record query
    $query = "/json-api/editzonerecord?zone=" . $GLOBALS['record_zone'] . "&Line=" . $record_line . "&address=" . $GLOBALS['record_address'] . "&type=A&class=IN&ttl=" . $GLOBALS['record_TTL'];
    // process query
    if (curl_request($query)) {
        echo "RECORD_UPDATED\n";
    }
}
////////////////
// INITIALIZE //
////////////////
// first see if we already have a record
$record_line = get_record_line();
// if we have it, update it, else create
if ($record_line > 0) {
    update_record($record_line);
} else {
    if ($record_line === -1) {
        add_record();
    }
}
Пример #6
0
<?php

require_once "functions.php";
include "connection.php";
?>

<?php 
switch (request_type()) {
    case 'GET':
        $id = $_GET["id"];
        echo get_record_json_by_id($id);
        break;
    case 'PUT':
        $json_str = file_get_contents('php://input');
        update_record($json_str);
        break;
    case 'DELETE':
        $id = $_GET["id"];
        delete_record_by_id($id);
        break;
    case 'POST':
        $json_str = file_get_contents('php://input');
        add_record($json_str);
        break;
    default:
        echo "unknown request";
        break;
}
Пример #7
0
if (!has_capability('block/tts:lexicon', $context)) {
    print 0;
    exit;
}
switch ($operation) {
    case 'get':
        get_table_records($courseid);
        break;
    case 'edit':
        edit_record();
        break;
    case 'del':
        del_record();
        break;
    case 'add':
        add_record($courseid);
        break;
    default:
        break;
}
/**
 * Add a record to the lexicon table
 * @global moodle_database $DB
 * @param int $courseid The course ID to the lexicon
 * @return null Return nothing. The result is printed
 */
function add_record($courseid)
{
    global $DB;
    $expression = optional_param('expression', '', PARAM_TEXT);
    $prenounce = optional_param('prenounce', '', PARAM_TEXT);