当前位置: 首页>>代码示例>>PHP>>正文


PHP printmsg函数代码示例

本文整理汇总了PHP中printmsg函数的典型用法代码示例。如果您正苦于以下问题:PHP printmsg函数的具体用法?PHP printmsg怎么用?PHP printmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printmsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ws_menu

function ws_menu($window_name, $form = '')
{
    global $conf, $images;
    $html = $js = '';
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    printmsg("DEBUG => Displaying tooltip: {$form['tooltip']}", 4);
    $menuname = 'get_html_' . $form['menu_name'];
    list($html, $js) = $menuname($form);
    // Okay here's what we do:
    //   1. Hide the tool-tip
    //   2. Update it's content
    //   3. Reposition it
    //   4. Unhide it
    $response = new xajaxResponse();
    if ($html) {
        $response->addScript("el('{$form['id']}').style.visibility = 'hidden';");
        $response->addAssign($form['id'], "innerHTML", $html);
        $response->addScript("wwTT_position('{$form['id']}'); el('{$form['id']}').style.visibility = 'visible';");
    }
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
开发者ID:edt82,项目名称:ona,代码行数:25,代码来源:menu_control.inc.php

示例2: checkmessage

function checkmessage($msg)
{
    if (isset($msg) && !empty($msg)) {
        $type = substr($msg, 0, 1);
        $msg = substr($msg, 1);
        printmsg($msg, $type);
    }
}
开发者ID:kellyegoodman,项目名称:CSCI-5448-Project,代码行数:8,代码来源:linkUsers_view.php

示例3: add_permission

function add_permission($options = "")
{
    global $conf, $self, $onadb;
    printmsg('DEBUG => add_permission(' . $options . ') called', 3);
    // Version - UPDATE on every edit!
    $version = '1.00';
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Return the usage summary if we need to
    if ($options['help'] or !$options['name']) {
        $self['error'] = 'ERROR => Insufficient parameters';
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

add_permission-v{$version}
Registers a new permission, this should be used by install scripts that are
creating new functionality that requires a registered permission.

  Synopsis: add_permission(OPTIONS)

  Options:
    name=STRING         Name of permission
    desc=STRING         Quoted string to describe this permission


EOM
);
    }
    // Get a list of the valid "permissions" and their descriptions.
    list($status, $rows, $permissions) = db_get_record($onadb, 'permissions', array('name' => $options['name']), '');
    if ($rows) {
        $self['error'] = "ERROR => add_permission() Permission already exists: {$options['name']}";
        printmsg($self['error'], 0);
        return array(1, $self['error'] . "\n");
    }
    // Get the next ID for the new host record
    $id = ona_get_next_id('permissions');
    if (!$id) {
        $self['error'] = "ERROR => The ona_get_next_id('permissions') call failed!";
        printmsg($self['error'], 0);
        return array(7, $self['error'] . "\n");
    }
    printmsg("DEBUG => ID for new permission record: {$id}", 3);
    // Add the record
    list($status, $rows) = db_insert_record($onadb, 'permissions', array('id' => $id, 'name' => $options['name'], 'description' => $options['desc']));
    if ($status or !$rows) {
        $self['error'] = "ERROR => add_permission() SQL Query failed: " . $self['error'];
        printmsg($self['error'], 0);
        return array(2, $self['error'] . "\n");
    }
    // Return the success notice
    $self['error'] = "INFO => Permission ADDED: {$options['name']} [{$options['desc']}]";
    printmsg($self['error'], 0);
    return array(0, $self['error'] . "\n");
}
开发者ID:edt82,项目名称:ona,代码行数:55,代码来源:permissions.inc.php

示例4: mangle_ip

function mangle_ip($options)
{
    global $conf, $self;
    printmsg('DEBUG => mangle_ip(' . $options . ') called', 3);
    // Version - UPDATE on every edit!
    $version = '1.00';
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Return the usage summary if we need to
    if ($options['help'] or !$options['ip']) {
        $self['error'] = 'ERROR => Insufficient parameters';
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

mangle_ip v{$version}
Converts between various IP address representations

  Synopsis: mangle_ip(OPTIONS)

  Required:
    ip=<inet_addr>  32 or 128-bit Internet address

  Optional:
    format=<specifier>  Desired output format, specified as a string
                        numeric : return ip as an integer
                        dotted  : return ip as an IPv4 address
                        cidr    : return ip as a CIDR netmask
                        binary  : return ip as a 32-bit binary string
                        bin128  : return ip as a 128-bit binary string
                        ipv6    : return ip as an IPv6 address
                        ipv6gz  : return ip as a compressed IPv6 address



EOM
);
    }
    // Now what?  We need to call ip_mangle() with our options
    if (!$options['format']) {
        $options['format'] = 'default';
    }
    $retval = ip_mangle($options['ip'], $options['format']) . "\n";
    if ($self['error'] != '') {
        return array(1, $self['error'] . "\n");
    } else {
        return array(0, $retval);
    }
}
开发者ID:edt82,项目名称:ona,代码行数:48,代码来源:mangle.inc.php

示例5: sess_read

function sess_read($key)
{
    global $SESS_DBH, $SESS_LIFE;
    printmsg("sess_read({$key}) called", 6);
    list($status, $rows, $record) = db_get_record($SESS_DBH, 'sessions', "`sesskey` = '{$key}' AND `expiry` > " . time());
    if ($status or $rows == 0) {
        return false;
    }
    if (array_key_exists('sessvalue', $record)) {
        // Update the expiry time (i.e. keep sessions alive even if nothing in the session has changed)
        $expiry = time() + $SESS_LIFE;
        list($status, $rows) = db_update_record($SESS_DBH, 'sessions', "`sesskey` = '{$key}' AND `expiry` > " . time(), array('expiry' => $expiry));
        if ($status) {
            return false;
        }
        // Return the value
        return $record['sessvalue'];
    }
    return false;
}
开发者ID:edt82,项目名称:ona,代码行数:20,代码来源:adodb_sessions.inc.php

示例6: ws_process_alerts_submit

function ws_process_alerts_submit($window_name, $form = '')
{
    global $conf, $self, $onadb, $tip_style;
    global $font_family, $color, $style, $images;
    $html = $js = '';
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    printmsg("DEBUG => Processing Alerts:", 5);
    // FIXME: this code is called from html_desktop.inc.php.. however it is failing to process for some reason
    // The intent of this code is to be called to display a "message waiting" type icon in the top menu bar.
    // Check for messages that begin with SYS_ in the table_name_ref column
    list($status, $rows, $msg) = db_get_record($onadb, 'messages', "table_name_ref LIKE 'SYS_%'");
    if ($rows) {
        $js .= "if (el('sys_alert')) {el('sys_alert').style.visibility = 'visible';}";
    } else {
        $js .= "if (el('sys_alert')) {el('sys_alert').style.visibility = 'hidden';}";
    }
    $response = new xajaxResponse();
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
开发者ID:edt82,项目名称:ona,代码行数:23,代码来源:process_alerts.inc.php

示例7: ws_interface_nat_save

function ws_interface_nat_save($window_name, $form = '')
{
    global $base, $include, $conf, $self, $onadb;
    // Check permissions
    if (!auth('interface_modify')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    $form = parse_options_string($form);
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $js = '';
    $refresh = "xajax_window_submit('list_interfaces', xajax.getFormValues('list_interfaces_filter_form'), 'display_list');";
    // Validate input
    if (!$form['ip'] and !$form['natip']) {
        $response->addScript("alert('Please complete all fields to continue!');");
        return $response->getXML();
    }
    // Decide if we're deleting or adding
    $module = 'nat_add';
    if ($form['nataction'] == "delete") {
        $module = 'nat_del';
    }
    // Do a pre check of the ptr domain so we can prompt the user properly
    if ($module == 'nat_add') {
        $ipflip = ip_mangle($form['natip'], 'flip');
        $octets = explode(".", $ipflip);
        list($status, $rows, $ptrdomain) = ona_find_domain($ipflip . ".in-addr.arpa");
        if (!$ptrdomain['id']) {
            printmsg("ERROR => This operation tried to create a PTR record that is the first in the {$octets[3]}.0.0.0 class A range.  You must first create at least the following DNS domain: {$octets[3]}.in-addr.arpa", 3);
            $self['error'] = "ERROR => This operation tried to create a PTR record that is the first in the {$octets[3]}.0.0.0 class A range.  You must first create at least the following DNS domain: {$octets[3]}.in-addr.arpa.  You could also create domains for class B or class C level reverse zones.  Click OK to open add domain dialog";
            $response->addScript("alert('{$self['error']}');xajax_window_submit('edit_domain', 'newptrdomainname=>{$octets[3]}.in-addr.arpa', 'editor');");
            return $response->getXML();
        }
    }
    // Run the module
    list($status, $output) = run_module($module, $form);
    // If the module returned an error code display a popup warning
    if ($status) {
        $js .= "alert('Save failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
    } else {
        $js .= "removeElement('{$window_name}');{$refresh}";
        if ($form['js']) {
            $js .= $form['js'];
        }
    }
    // Insert the new table into the window
    $response->addScript($js);
    return $response->getXML();
}
开发者ID:edt82,项目名称:ona,代码行数:51,代码来源:tooltips.inc.php

示例8: ona_sql

function ona_sql($options = "")
{
    // The important globals
    global $conf, $onadb, $base;
    // Version - UPDATE on every edit!
    $version = '1.05';
    // TODO: Maybe make this into a sys_config option
    $srvdir = dirname($base) . "/sql";
    printmsg('DEBUG => ona_sql(' . $options . ') called', 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize delimeter
    if (!$options['delimiter']) {
        $options['delimiter'] = ':';
    }
    // fix up the escaped ' marks.  may need the = and & stuff too????
    $options['sql'] = str_replace('\\\'', '\'', $options['sql']);
    $options['sql'] = str_replace('\\=', '=', $options['sql']);
    // Set "options[commit] to no if it's not set
    if (!array_key_exists('commit', $options)) {
        $options['commit'] = 'N';
    } else {
        $options['commit'] = sanitize_YN($options['commit'], 'N');
    }
    // Set "options[commit] to no if it's not set
    if (!array_key_exists('dataarray', $options)) {
        $options['dataarray'] = 'N';
    } else {
        $options['dataarray'] = sanitize_YN($options['dataarray'], 'N');
    }
    // Set "options[header] to yes if it's not set
    if (!array_key_exists('header', $options)) {
        $options['header'] = 'Y';
    } else {
        $options['header'] = sanitize_YN($options['header'], 'Y');
    }
    // Check permissions
    if (!auth('ona_sql')) {
        $self['error'] = "Permission denied!";
        printmsg($self['error'], 0);
        return array(10, $self['error'] . "\n");
    }
    // Return the usage summary if we need to
    if ($options['help'] or !($options['list'] and !$options['sql'] or !$options['list'] and $options['sql'])) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

ona_sql-v{$version}
Runs the specified SQL query on the database and prints the result

  Synopsis: ona_sql [KEY=VALUE] ...

  Required:
    sql=STATEMENT|FILENAME   quoted SQL statement to execute
    OR
    list                     lists the SQL files available on the server side

  Optional:
    show                     displays contents of SQL, gives usage etc
    commit=yes|no            commit the transaction (no)
    header=yes|no            display record header (yes)
    delimiter=DELIMITER      record delimiter for output (:)
    (1,2,..)=VALUE           bind variables, replaces ? in query sequentially.
                             the first ? found is replaced by 1=value, and so on

  Notes:
    * Query is sent to the configured OpenNetAdmin database server.
    * The use of bind variables requires your options to match positionally.
    * The SQL option will be tried first as a local file, then as a server
      file, then as a raw text SQL query.  Filenames are case sensitive.
    * Server based SQL files are located in {$srvdir}
    * Some plugins may provide their own SQL dir inside the plugin directory
    * Use the show option to display contents of SQL files, this should contain
      a long description and any usage information that is needed.


EOM
);
    }
    // TODO: check that the user has admin privs? or at least a ona_sql priv
    // Get a list of the files
    $plugins = plugin_list();
    $files = array();
    $srvdirs = array();
    array_push($srvdirs, $srvdir);
    // add a local sql dir as well so they don't get overrriden by installs
    array_push($srvdirs, dirname($base) . '/www/local/sql');
    // loop through the plugins and find files inside of their sql directories.
    foreach ($plugins as $plug) {
        array_push($srvdirs, $plug['path'] . '/sql');
    }
    // Loop through each of our plugin directories and the default directory to find .sql files
    foreach ($srvdirs as $srvdir) {
        if ($handle = @opendir($srvdir)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != ".." && substr($file, -4) == '.sql') {
                    // Build an array of filenames
                    array_push($files, $srvdir . '/' . $file);
                }
            }
//.........这里部分代码省略.........
开发者ID:edt82,项目名称:ona,代码行数:101,代码来源:sql.inc.php

示例9: dns_record_display

function dns_record_display($options = "")
{
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.00';
    printmsg("DEBUG => dns_record_display({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize options[verbose] (default is yes)
    $options['verbose'] = sanitize_YN($options['verbose'], 'Y');
    // Return the usage summary if we need to
    if ($options['help'] or !$options['name']) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        $self['error'] = 'ERROR => Insufficient parameters';
        return array(1, <<<EOM

dns_record_display-v{$version}
Displays a DNS record from the database

  Synopsis: dns_record_display [KEY=VALUE] ...

  Required:
    name=NAME[.DOMAIN] or ID      hostname or ID of the dns record to display

  Optional:
    verbose=[yes|no]              display additional info (yes)



EOM
);
    }
    // If the name we were passed has a leading . in it then remove the dot.
    $options['name'] = preg_replace("/^\\./", '', $options['name']);
    // Find the DNS record from $options['name']
    list($status, $rows, $record) = ona_find_dns_record($options['name']);
    printmsg("DEBUG => dns_record_del() DNS record: {$record['name']}", 3);
    if (!$record['id']) {
        printmsg("DEBUG => Unknown DNS record: {$options['name']}", 3);
        $self['error'] = "ERROR => Unknown DNS record: {$options['name']}";
        return array(2, $self['error'] . "\n");
    }
    // Build text to return
    $text = "DNS {$record['type']} RECORD ({$record['fqdn']})\n";
    $text .= format_array($record);
    // If 'verbose' is enabled, grab some additional info to display
    if ($options['verbose'] == 'Y') {
        // PTR record(s)
        $i = 0;
        do {
            list($status, $rows, $ptr) = ona_get_dns_record(array('dns_id' => $record['id'], 'type' => 'PTR'));
            if ($rows == 0) {
                break;
            }
            $i++;
            $text .= "\nASSOCIATED PTR RECORD ({$i} of {$rows})\n";
            $text .= format_array($ptr);
        } while ($i < $rows);
        // CNAME record(s)
        $i = 0;
        do {
            list($status, $rows, $cname) = ona_get_dns_record(array('dns_id' => $record['id'], 'type' => 'CNAME'));
            if ($rows == 0) {
                break;
            }
            $i++;
            $text .= "\nASSOCIATED CNAME RECORD ({$i} of {$rows})\n";
            $text .= format_array($cname);
        } while ($i < $rows);
        // FIXME: MP display other types of records like NS,MX,SRV etc etc, also support dns views better
    }
    // Return the success notice
    return array(0, $text);
}
开发者ID:edt82,项目名称:ona,代码行数:74,代码来源:dns_record.inc.php

示例10: build_dhcpd_conf

function build_dhcpd_conf($options = "")
{
    global $self;
    global $conf;
    global $onadb;
    // Version - UPDATE on every edit!
    $version = '1.10';
    // Exit status of the function
    $exit = 0;
    printmsg('DEBUG => build_dhcpd_conf(' . $options . ') called', 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Return the usage summary if we need to
    if ($options['help'] or !$options['server']) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

build_dhcpd_conf-v{$version}
Builds configuration for dhcpcd from the database

  Synopsis: build_dhcpd_conf [KEY=VALUE] ...

  Required:
    server=NAME[.DOMAIN] or ID    Build conf by hostname or HOST_ID

  Optional:
    header_path=PATH              Path to the server local header to include

  Notes:
    * Specified host must be a valid DHCP server
    * header_path is a file on the DHCP server.  It will be defined at
      the very top of your configuration using the DHCP "include" directive.


EOM
);
    }
    // TODO: ipv6 need to pass in if we want v4 or v6.. default to v4 for now.
    //       looks like you cant have a mixed config
    // Debugging
    printmsg("DEBUG => Building DHCP config for: {$options['server']}", 3);
    // Validate that there is already a host named $options['server'].
    list($status, $rows, $host) = ona_find_host($options['server']);
    if (!$host['id']) {
        return array(2, "ERROR => No such host: {$options['server']}\n");
    }
    // Now determine if that host is a valid server
    list($status, $dhcp_rows, $dhcp_server) = db_get_records($onadb, 'dhcp_server_subnets', array('host_id' => $host['id']), '');
    list($status, $dhcpf_rows, $dhcpf_server) = db_get_records($onadb, 'dhcp_failover_groups', "primary_server_id = {$host['id']} or secondary_server_id = {$host['id']}", '');
    if ($dhcp_rows == 0 and $dhcpf_rows == 0) {
        return array(3, "ERROR => Specified host is not a DHCP server: {$options['server']}\n");
    }
    // Throw the host id into a self variable for later use
    $self['serverid'] = $host['id'];
    // Start an output variable with build timestamp
    $text .= "###### DO NOT EDIT THIS FILE ###### \n";
    $text .= "# dhcpd.conf file for {$host['fqdn']} built on " . date($conf['date_format']) . "\n#\n";
    $text .= "# This file is built by an automated script.  Any change to this \n";
    $text .= "# file will be lost at the next build.\n\n";
    // setup standard include path
    // TODO: MP possibly put this into a configuration option like header so the user can easily change where this is.
    if (isset($options['header_path'])) {
        $text .= "include \"{$options['header_path']}\";\n";
    }
    /////////////////////////////// Build global options //////////////////////////////////////////
    list($status, $globals) = build_global($host['id']);
    $text .= $globals;
    /////////////////////////////// Failover groups //////////////////////////////////////////
    // build list of failover group statements for provided server
    list($status, $failovergroup) = ona_dhcp_build_failover_group($host['id']);
    $text .= $failovergroup;
    /////////////////////////////// shared subnets //////////////////////////////////////////
    // setup a variable to keep track of which vlan we are on
    $vlananchor = '';
    // Loop through all of the vlan subnets and print them
    printmsg("DEBUG => Processing all Shared (VLAN) Subnets", 1);
    $i = 0;
    do {
        list($status, $rows, $vlan_subnet) = ona_get_record('vlan_id != 0 AND
                                                              id IN (SELECT subnet_id
                                                                     FROM   dhcp_server_subnets
                                                                     WHERE  host_id = ' . $host['id'] . '
                                                                     UNION
                                                                     SELECT subnet_id
                                                                     FROM dhcp_pools
                                                                     WHERE dhcp_failover_group_id IN (SELECT id
                                                                                                      FROM dhcp_failover_groups
                                                                                                      WHERE primary_server_id = ' . $host['id'] . '
                                                                                                      OR secondary_server_id = ' . $host['id'] . '))', 'subnets', 'vlan_id ASC');
        if ($status) {
            printmsg($self['error'], 0);
            $exit += $status;
        }
        if ($rows == 0) {
            printmsg("DEBUG => build_dhcpd_conf(): Found no shared subnets.", 3);
            break;
        } else {
            if ($i == 0) {
                $text .= "# --------SHARED SUBNETS (count={$rows})--------\n\n";
            }
//.........这里部分代码省略.........
开发者ID:chuhn,项目名称:build_isc_dhcp,代码行数:101,代码来源:build_isc_dhcp.inc.php

示例11: temp

        $CurrPag = 0;
    }
    if ($CurrPag < 0) {
        $CurrPag = 0;
    }
    $postlink = $CurrPag * $PostXPage + 1;
    $db->query("replace temp(chiave,valore,TTL) values ('" . $_REQUEST['THR_ID'] . "',{$Num3d}," . (time() + 2592000) . ");");
    $db->query("update {$SNAME}_msghe set read_num=read_num+1 WHERE HASH='" . mysql_escape_string($MSGID) . "';");
    // *** convertire searcher.pm prima di attivare questa funzione ***
    //echo "<a href=\"searcher.pm?MODO=2&amp;REP_OF=".urlencode($MSGID)."\">";
    //echo $lang['shmsg_findnewmsg']."</a><br />";
    PageSelect(1);
    if ($CurrPag < 1) {
        printmsg($riga, $postlink - 1);
    }
    $query = "SELECT edit.TITLE AS title, edit.BODY AS body, membri.AUTORE as autore, " . " (origi.DATE+" . GMT_TIME . ") as 'date', (membri.DATE+" . GMT_TIME . ") AS regdate, membri.avatar AS avatar, membri.firma AS firma," . " membri.is_auth AS 'is_auth', membri.msg_num AS 'msg_num'," . " membri.title as 'gruppo', membri.HASH AS 'memhash',origi.HASH AS 'hash', edit.REP_OF AS 'repof'," . " edit.EDIT_OF AS 'edit_of', edit.HASH AS 'real_hash', edit.AUTORE AS 'real_autore', (edit.DATE+" . GMT_TIME . ") AS 'real_date'" . " FROM `{$SNAME}_reply` AS origi, `{$SNAME}_reply` AS edit, `{$SNAME}_membri` AS membri\r\n\t   WHERE edit.EDIT_OF=origi.HASH" . " AND membri.HASH=origi.AUTORE" . " AND edit.REP_OF='" . mysql_escape_string($MSGID) . "'" . " AND edit.visibile='1'" . " ORDER BY origi.DATE" . " LIMIT " . $CurrPag * $PostXPage . ",{$PostXPage};";
    $risultato = $db->get_results($query);
    if ($risultato) {
        foreach ($risultato as $riga) {
            printmsg($riga, $postlink);
            $postlink++;
        }
    }
    PageSelect(2);
    FastReply();
}
?>
</td>
</tr>
<?php 
include "end.php";
开发者ID:BackupTheBerlios,项目名称:keyforum-svn,代码行数:31,代码来源:showmsg.php

示例12: run_module

function run_module($module = '', $options = '', $transaction = 1)
{
    global $conf, $self, $onadb;
    // Build the options array string from $options_string if we need to
    // This is only used for logging!  If $options_string is an array it
    // is passed untouched to the module.
    $options_string = $options;
    if (is_array($options)) {
        $options_string = '';
        $and = '';
        foreach (array_keys($options) as $key) {
            // Quote any "special" characters in the value.
            // Specifically the '=' and '&' characters need to be escaped.
            $options[$key] = str_replace(array('=', '&'), array('\\=', '\\&'), $options[$key]);
            // If the key has no value or it is the javascript key, dont print it.
            if ($options[$key] != "" and $key != 'js') {
                $options_string .= "{$and}{$key}={$options[$key]}";
                $and = '&';
            }
        }
    }
    // get the options as an array so we can look for logging info
    $local_options = parse_options($options);
    // If the user passes in an option called 'module_loglevel' then use it as the run module output level
    // otherwise default it to 1 so it will print out as normal.
    $log_level = 1;
    if ($local_options['module_loglevel']) {
        $log_level = $local_options['module_loglevel'];
    }
    // Remove config info as it can be huge and could have sensitive info in it.
    // This could cause issues since I"m doing & as an anchor at the end.  see how it goes.
    // The module that is called could also display this information depending on debug level
    $options_string = preg_replace("/config=.*&/", '', $options_string);
    printmsg("INFO => Running module: {$module} options: {$options_string}", $log_level);
    // Load the module
    if (load_module($module)) {
        return array(1, $self['error'] . "\n");
    }
    // Start an DB transaction (If the database supports it)
    if ($transaction) {
        $has_trans = $onadb->BeginTrans();
    }
    if (!$has_trans) {
        printmsg("WARNING => Transactions support not available on this database, this can cause problems!", 1);
    }
    // If begintrans worked and we support transactions, do the smarter "starttrans" function
    if ($has_trans) {
        printmsg("DEBUG => Commiting transaction", 2);
        $onadb->StartTrans();
    }
    // Start a timer so we can display moudle run time if debugging is enabled
    $start_time = microtime_float();
    // Run the function
    list($status, $output) = $module($options);
    // Stop the timer, and display how long it took
    $stop_time = microtime_float();
    printmsg("DEBUG => [Module_runtime] " . round($stop_time - $start_time, 2) . " seconds -- [Total_SQL_Queries] " . $self['db_get_record_count'] . " --  [Module_exit_code] {$status}", 1);
    // Either commit, or roll back the transaction
    if ($transaction and $has_trans) {
        if ($status != 0) {
            printmsg("INFO => There was a module error, marking transaction for a Rollback!", 1);
            //$onadb->RollbackTrans();
            $onadb->FailTrans();
        }
    }
    if ($has_trans) {
        // If there was any sort of failure, make sure the status has incremented, this catches sub module output errors;
        if ($onadb->HasFailedTrans()) {
            $status = $status + 1;
        }
        // If the user passed the rollback flag then dont commit the transaction
        // FIXME: not complete or tested.. it would be nice to have an ability for the user to pass
        //        a rollback flag to force the transaction to rollback.. good for testing adds/modify.
        //        The problem is sub modules will fire and then the whole thing stops so you wont see/test the full operation.
        //         if ($local_options['rollback']) {
        //             printmsg("INFO => The user requested to mark the transaction for a rollback, no changes made.", 0);
        //             $output .= "INFO => The user requested to mark the transaction for a rollback, no changes made.\n";
        //             $status = $status + 1;
        //         }
        printmsg("DEBUG => Commiting transaction", 2);
        $onadb->CompleteTrans();
    }
    // Return the module's output
    return array($status, $output);
}
开发者ID:edt82,项目名称:ona,代码行数:85,代码来源:functions_general.inc.php

示例13: fwrite

             fwrite($fh, "<?php\n\n\$ona_contexts=" . var_export($ona_contexts, TRUE) . ";\n\n?>");
             fclose($fh);
             $text .= "<img src=\"{$images}/silk/accept.png\" border=\"0\" /> Created database connection config file.<br>";
         }
         // Update the version element in the sys_config table
         if (@$db->Execute("UPDATE sys_config SET value='{$new_ver}' WHERE name like 'version'")) {
             // $text .= "<img src=\"{$images}/silk/accept.png\" border=\"0\" /> Updated local version info.<br>";
         } else {
             $status++;
             $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to update version info in table 'sys_config'.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
         }
     }
 } else {
     $status++;
     $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to select DB '{$database_name}'.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
     printmsg("ERROR => Failed to select DB: {$database_name}.  " . $db->ErrorMsg(), 0);
 }
 if ($status > 0) {
     $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> There was a fatal error. Install may be incomplete. Fix the issue and <a href=\"{$baseURL}\">try again</a>.<br>";
 } else {
     // remove the run_install file in the install dir
     if (@file_exists($runinstall)) {
         if (!@unlink($runinstall)) {
             $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to delete the file '{$runinstall}'.<br>";
             $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Please remove '{$runinstall}' manually.<br>";
         }
     }
     $text .= "You can now <a href='" . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) . "'>CLICK HERE TO START</a> using OpenNetAdmin!<br>You can log in as 'admin' with a password of 'admin'<br>Enjoy!";
 }
 // Close the database connection
 @$db->Close();
开发者ID:edt82,项目名称:ona,代码行数:31,代码来源:install.php

示例14: config_diff

function config_diff($options = "")
{
    // The important globals
    global $conf;
    global $self;
    global $onadb;
    // Version - UPDATE on every edit!
    $version = '1.03';
    printmsg('DEBUG => config_diff(' . $options . ') called', 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Return the usage summary if we need to
    if ($options['help'] or (!$options['host'] or !$options['type']) and (!$options['ida'] or !$options['idb'])) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

config_diff-v{$version}
Displays the difference between selected archive entries
  
  Synopsis: config_diff [KEY=VALUE] ...
  
  Required:
    host=ID or NAME[.DOMAIN]    display most recent config for specified host
    type=TYPE                   type of config to display -
                                  usually "IOS_VERSION" or "IOS_CONFIG"
     OR
    ida=ID                      First config ID to compare against idb
    idb=ID                      Second config ID to compare against ida

  Note:
    If you don't pass any IDs you will get the two most recent configs
    related to the host/type you provide.

EOM
);
    }
    $text = "";
    // Compare arbitrary configs based on config IDs
    // If we have ids, lets use those instead
    if ($options['ida'] and $options['idb']) {
        // get the two configs from the db
        list($status, $rows, $configs) = db_get_records($onadb, 'configurations', "id in ({$options['ida']},{$options['idb']})", 'ctime DESC', '2', '');
    } else {
        // Get a config record if there is one
        $self['error'] = "";
        list($status, $rows, $config) = ona_find_config($options);
        list($status, $rows, $configs) = db_get_records($onadb, 'configurations', array('host_id' => $config['host_id'], 'configuration_type_id' => $config['configuration_type_id']), 'ctime DESC', '2', '');
    }
    // Error if an error was returned
    if ($status or $rows != 2) {
        if ($self['error']) {
            $text = $self['error'] . "\n";
        }
        $text .= "ERROR => One or more config text entries not found!\n";
        return array(2, $text);
    }
    // Get a unified text diff output
    $text .= text_diff($configs[1]['config_body'], $configs[0]['config_body']);
    // Return the success notice
    return array(0, $text);
}
开发者ID:edt82,项目名称:ona,代码行数:61,代码来源:configuration.inc.php

示例15: block_display

function block_display($options = "")
{
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.00';
    printmsg("DEBUG => block_display({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize options[verbose] (default is yes)
    $options['verbose'] = sanitize_YN($options['verbose'], 'Y');
    // Return the usage summary if we need to
    if ($options['help'] or !$options['block']) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        $self['error'] = 'ERROR => Insufficient parameters';
        return array(1, <<<EOM

block_display-v{$version}
Displays a block record from the database

  Synopsis: block_display [KEY=VALUE] ...

  Required:
    block=NAME or ID      Block name or ID of the block display

  Optional:
    verbose=[yes|no]      Display additional info (DEFAULT: yes)


EOM
);
    }
    // The formatting rule on block names is all upper and trim it
    $options['block'] = trim($options['block']);
    $options['block'] = preg_replace('/\\s+/', '-', $options['block']);
    $options['block'] = strtoupper($options['block']);
    // If the block provided is numeric, check to see if it's an block
    if (is_numeric($options['block'])) {
        // See if it's an block_id
        list($status, $rows, $block) = ona_get_block_record(array('id' => $options['block']));
        if (!$block['id']) {
            printmsg("DEBUG => Unable to find block using the ID {$options['block']}!", 3);
            $self['error'] = "ERROR => Unable to find block using the ID {$options['block']}!";
            return array(2, $self['error'] . "\n");
        }
    } else {
        list($status, $rows, $block) = ona_get_block_record(array('name' => $options['block']));
        if (!$block['id']) {
            $self['error'] = "ERROR => Unable to find block using the name {$options['block']}!";
            printmsg("DEBUG => Unable to find block using the name {$options['block']}!", 3);
            return array(2, $self['error'] . "\n");
        }
    }
    printmsg("DEBUG => Found block: {$block['name']}", 3);
    // Build text to return
    $text = "BLOCK RECORD\n";
    $text .= format_array($block);
    // If 'verbose' is enabled, grab some additional info to display
    if ($options['verbose'] == 'Y') {
        $where .= " ip_addr >= " . $block['ip_addr_start'] . " AND ip_addr <= " . $block['ip_addr_end'];
        list($status, $netrows, $nets) = db_get_records($onadb, 'subnets', $where, "ip_addr");
        // subnet record(s)
        $i = 0;
        foreach ($nets as $record) {
            list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $record['id']));
            if ($rows == 0) {
                break;
            }
            $i++;
            $text .= "\nASSOCIATED SUBNET RECORD ({$i} of {$netrows})\n";
            $text .= format_array($subnet);
        }
    }
    // Return the success notice
    return array(0, $text);
}
开发者ID:edt82,项目名称:ona,代码行数:75,代码来源:block.inc.php


注:本文中的printmsg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。