コード例 #1
1
ファイル: vote_manager.php プロジェクト: haseok86/millkencode
function editvote($eV)
{
    global $db;
    $resp = new xajaxResponse();
    $i = 0;
    foreach ($eV['id'] as $v) {
        $db->query("UPDATE `vote` SET custom1='" . m_addslashes($eV['zd1'][$i]) . "',custom2='" . m_addslashes($eV['zd2'][$i]) . "' WHERE id=" . $v . "") or error('Unable to update vote.', __FILE__, __LINE__, $db->error());
        $i++;
    }
    $resp->alert("更新成功");
    return $resp->getXML();
}
コード例 #2
0
ファイル: drag.inc.php プロジェクト: edt82/ona
function window_save_position($element, $x, $y)
{
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    if (!$element or !$x or !$y) {
        return $response->getXML();
    }
    // Search the DB
    if ($x > 0 and $y > 0 and $x < 3000 and $y < 3000) {
        $_SESSION['window_position']["{$element}_x"] = $x;
        $_SESSION['window_position']["{$element}_y"] = $y;
    }
    return $response->getXML();
}
コード例 #3
0
ファイル: suggest.inc.php プロジェクト: edt82/ona
function suggest($type, $q, $el_input, $el_suggest)
{
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    if (!$type or !$q or !$el_input or !$el_suggest) {
        return $response->getXML();
    }
    // Make sure the requested function is defined
    $function = 'suggest_' . $type;
    if (function_exists($function)) {
        return $function($q, $el_input, $el_suggest);
    }
    return $response->getXML();
}
コード例 #4
0
ファイル: edit_tag.inc.php プロジェクト: edt82/ona
function ws_delete($window_name, $form = '')
{
    global $base, $include, $conf, $self, $onadb;
    // Check permissions
    if (!(auth('host_del') or auth('subnet_del'))) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $js = '';
    // Run the module
    list($status, $output) = run_module('tag_del', array('tag' => $form['id'], 'commit' => 'Y'));
    // If the module returned an error code display a popup warning
    if ($status) {
        $js .= "alert('Delete failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
    } else {
        // If there's (refresh) js, send it to the browser
        if ($form['js']) {
            $js .= $form['js'];
        }
    }
    // Return an XML response
    $response->addScript($js);
    return $response->getXML();
}
コード例 #5
0
function testRegularFunction($formData)
{
    $objResponse = new xajaxResponse();
    $objResponse->addAlert("formData: " . print_r($formData, true));
    $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)));
    return $objResponse->getXML();
}
コード例 #6
0
function removeInput($aInputData)
{
    $sId = $aInputData['inputId'];
    $objResponse = new xajaxResponse();
    $objResponse->addRemove($sId);
    return $objResponse->getXML();
}
コード例 #7
0
function test()
{
    $objResponse = new xajaxResponse();
    $objResponse->addAlert("hallo");
    $objResponse->addAssign('testButton', 'label', 'Success!');
    return $objResponse->getXML();
}
コード例 #8
0
 function testClassMethod($formData)
 {
     $objResponse = new xajaxResponse();
     $objResponse->addAlert("This is a class method.");
     $objResponse->addAlert("formData: " . print_r($formData, true));
     $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)));
     return $objResponse->getXML();
 }
コード例 #9
0
ファイル: connected_users.php プロジェクト: r3-gis/EcoGIS
function disconnectUser($dn_name, $us_login)
{
    global $auth;
    $objResponse = new xajaxResponse();
    $auth->disconnectUser($dn_name, $us_login);
    $objResponse->addScript("document.location='connected_users.php'");
    return $objResponse->getXML();
}
コード例 #10
0
function testForm($formData, $strText)
{
    global $useEncoding, $htmlEntities;
    $objResponse = new xajaxResponse($useEncoding, $htmlEntities);
    $objResponse->addAlert("formData: " . print_r($formData, true) . $strText);
    $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)) . '<br /><br />' . $strText);
    return $objResponse->getXML();
}
コード例 #11
0
function myErrorRiddenFunction()
{
    $value = $silly['nuts'];
    $objResponse = new xajaxResponse();
    $objResponse->addAlert("Bad array value: {$value}");
    include "file_doesnt_exist.php";
    return $objResponse->getXML();
}
コード例 #12
0
function confirmTest()
{
    $objResponse = new xajaxResponse();
    $objResponse->addAlert("Here is an alert.");
    $objResponse->addConfirmCommands(2, "Are you sure you want to show two (2) more alerts?");
    $objResponse->addAlert("This will only happen if the user presses OK.");
    $objResponse->addAlert("This also will only happen if the user presses OK.");
    $objResponse->addAlert("This will always happen.");
    return $objResponse->getXML();
}
コード例 #13
0
ファイル: acnames_edit_ajax.php プロジェクト: r3-gis/EcoGIS
function submitForm($elems, $doneFunc = 'AjaxFormObj.checkDone', $errFunc = 'AjaxFormObj.checkError')
{
    global $lbl, $txt;
    $auth = R3AuthInstance::get();
    $fieldDescr = array('app_code' => array(MISSING_FIELD => !isset($txt['missing_fld_app']) ? _("Il campo 'applicazione' e' obbligatorio") : $txt['missing_fld_app'], INVALID_FIELD => "Il campo 'codice' contiene caratteri non validi. Solo lettere e numeri sono accettati", PK_ERROR => "Il campo 'codice' immesso esiste gia'"), 'app_name' => array(MISSING_FIELD => "Il campo 'nome' e' obbligatorio"));
    // print_r($elems);
    $elems = AjaxSplitArray($elems);
    //print_r($elems);
    $objResponse = new xajaxResponse();
    $error = array();
    try {
        if ($elems['act'] == 'add') {
            /** add a new acname */
            foreach (explode(',', str_replace(';', ',', $elems['ac_verb'])) as $verb) {
                $auth->addACName($elems['app_code'], strtoupper(trim($verb)), strtoupper(trim($elems['ac_name'])), trim($elems['ac_descr']), trim($elems['ac_order']), strtoupper($elems['ac_active']) == 'T', array('ac_type' => strtoupper($elems['ac_type'])));
            }
        } else {
            if ($elems['act'] == 'mod') {
                /** modify an acname */
                $auth->modACName($elems['old_app_code'], $elems['old_ac_verb'], $elems['old_ac_name'], $elems['app_code'], strtoupper(trim($elems['ac_verb'])), strtoupper(trim($elems['ac_name'])), trim($elems['ac_descr']), trim($elems['ac_order']), strtoupper($elems['ac_active']) == 'T', array('ac_type' => strtoupper($elems['ac_type'])));
            } else {
                if ($elems['act'] == 'del') {
                    /** delete an acname */
                    $auth->delACName($elems['app_code'], $elems['ac_verb'], $elems['ac_name']);
                } else {
                    throw new Exception('Invalid action');
                }
            }
        }
    } catch (EPermissionDenied $e) {
        $error['element'][] = '';
        $error['message'][] = $e->getMessage();
    } catch (EDatabaseError $e) {
        $error['element'][] = '';
        $error['message'][] = "Database error: " . $e->getMessage();
    } catch (EInputError $e) {
        $error['element'][] = $e->getField();
        if (isset($fieldDescr[$e->getField()][$e->getCode()])) {
            $error['message'][] = $fieldDescr[$e->getField()][$e->getCode()];
        } else {
            $error['message'][] = $e->getMessage();
        }
    } catch (Exception $e) {
        $error['element'][] = '';
        $error['message'][] = 'Generic error: ' . $e->getMessage();
    }
    // Action
    if (count($error) > 0) {
        $errText = (!isset($txt['err_store_failed']) ? _("Salvataggio fallito") . ":" : $txt['err_store_failed']) . "\n - " . implode("\n - ", $error['message']);
        $objResponse->addScriptCall($errFunc, $errText, $error['element'][0]);
    } else {
        $objResponse->addScriptCall($doneFunc);
    }
    return $objResponse->getXML();
}
コード例 #14
0
function objectscount($fid, $confid)
{
    $objResponse = new xajaxResponse();
    $pp = do_objectscount($fid, $confid);
    //½«ÌíÈëÊýÁ¿
    $objResponse->addAssign("objectnum", "disabled", false);
    $objResponse->addAssign("objectnum", "value", $pp);
    $objResponse->addAssign("max", "value", $pp);
    $objResponse->addAssign("doit", "disabled", false);
    return $objResponse->getXML();
}
コード例 #15
0
function testForm($strText, $formData, $arrArray)
{
    global $useEncoding, $htmlEntities;
    $objResponse = new xajaxResponse($useEncoding, $htmlEntities);
    $data = "Text:\n" . $strText;
    $data .= "\n\nFormData:\n" . print_r($formData, true);
    $data .= "\n\nArray:\n" . print_r($arrArray, true);
    $objResponse->addAlert($data);
    $objResponse->addAssign("submittedDiv", "innerHTML", "<pre>" . $data . "</pre>");
    return $objResponse->getXML();
}
コード例 #16
0
ファイル: xajax.php プロジェクト: HaakonME/porticoestate
/**
 * callback if the session-check fails, redirects via xajax to login.php
 * 
 * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
 * @return boolean/string true if we allow anon access and anon_account is set, a sessionid or false otherwise
 */
function xajax_redirect(&$anon_account)
{
    // now the header is included, we can set the charset
    $GLOBALS['xajax']->setCharEncoding('utf-8');
    define('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8');
    $response = new xajaxResponse();
    $response->addScript("location.href='" . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php?cd=10' . "';");
    header('Content-type: text/xml; charset=' . 'utf-8');
    echo $response->getXML();
    $GLOBALS['phpgw']->common->phpgw_exit();
}
コード例 #17
0
ファイル: changeusers.php プロジェクト: noikiy/owaspbwa
function chkPassword($value)
{
    $mtview_controller = new MTViewController();
    $matchResult = $mtview_controller->xajaxObjCall($value, 'CPW', 'password');
    $objResponse = new xajaxResponse();
    if ($matchResult) {
        $objResponse->addScript("addUpdate();");
    } else {
        $objResponse->addAlert($GLOBALS['lang_Admin_Users_ErrorsPasswordMismatch']);
    }
    return $objResponse->getXML();
}
コード例 #18
0
ファイル: quote.server.php プロジェクト: neofutur/MyBestBB
function quote($pid)
{
    global $db, $pun_user;
    $objResponse = new xajaxResponse();
    $ret = "";
    $result = $db->query('SELECT poster, message FROM ' . $db->prefix . 'posts WHERE id=' . $pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    $cur_post = $db->fetch_assoc($result);
    //  $quotemsg = utf8_encode("[quote=" . $cur_post['poster'] . "]" . $cur_post['message'] . "[/quote]\n");
    $quotemsg = "[quote=" . $cur_post['poster'] . "]" . $cur_post['message'] . "[/quote]\n";
    $objResponse->addAppend("req_message", "value", $quotemsg);
    $objResponse->addAssign("req_message", "style.height", "300px");
    return $objResponse->getXML();
}
コード例 #19
0
function showOutput()
{
    $testResponse = new xajaxResponse();
    $testResponse->addAlert("Hello");
    //	$testResponseOutput = htmlspecialchars($testResponse->getXML());
    $testResponse2 = new xajaxResponse();
    $testResponse2->loadXML($testResponse->getXML());
    $testResponse2->addReplace("this", "is", "a", "replacement");
    $testResponseOutput = htmlspecialchars($testResponse2->getXML());
    $objResponse = new xajaxResponse();
    $objResponse->addAssign("submittedDiv", "innerHTML", $testResponseOutput);
    return $objResponse;
}
コード例 #20
0
ファイル: ipcalcgui.inc.php プロジェクト: edt82/ona
function ws_ipcalcgui_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);
    $text = '';
    $ipinfo = ipcalc_info($form['ip'], $form['mask']);
    // MP: I removed the following as they are tooooo large
    //bin128:  {$ipinfo['ip_bin128']}
    //bin128:      {$ipinfo['mask_bin128']}
    // NOTE: yes it is annoying but I had to do the <br> thing due to windows
    // not being able to handle the new lines via a standard <pre> statement.
    // I went with this as it keeps things consistant between platforms.  The pre is now a span
    $text .= <<<EOL
<br />
<br />
Input: IP={$ipinfo['in_ip']}    MASK={$ipinfo['in_mask']}<br />
<br />
IP={$ipinfo['in_ip']}<br />
  Dotted:  {$ipinfo['ip_dotted']}<br />
  Numeric: {$ipinfo['ip_numeric']}<br />
  binary:  {$ipinfo['ip_binary']}<br />
  ipv6:    {$ipinfo['ip_ipv6']}<br />
  ipv6gz:  {$ipinfo['ip_ipv6gz']}<br />
  flip:    {$ipinfo['ip_flip']}<br />
<br />
MASK={$ipinfo['mask_dotted']}<br />
  Dotted:      {$ipinfo['mask_dotted']}<br />
  Numeric:     {$ipinfo['mask_numeric']}<br />
  Cidr:        /{$ipinfo['mask_cidr']}<br />
  binary:      {$ipinfo['mask_binary']}<br />
  bin invert:  {$ipinfo['mask_bin_invert']}<br />
  ipv6:        {$ipinfo['mask_ipv6']}<br />
  ipv6gz:      {$ipinfo['mask_ipv6gz']}<br />
  flip:        {$ipinfo['mask_flip']}<br />
  IP invert:   {$ipinfo['mask_dotted_invert']}<br />
<br />
The subnet your IP falls in is:   {$ipinfo['truenet']}/{$ipinfo['mask_cidr']} ({$ipinfo['mask_dotted']})<br />
<br />
Total addresses using this mask:  {$ipinfo['ip_total']}<br />
Usable addresses using this mask: {$ipinfo['ip_usable']}<br />
Last address using this mask:     {$ipinfo['ip_last']}<br />
<br />

EOL;
    $response = new xajaxResponse();
    $response->addAssign('ipcalc_data', "innerHTML", $text);
    return $response->getXML();
}
コード例 #21
0
ファイル: jobtitle.php プロジェクト: noikiy/owaspbwa
function showEditEmpStatForm($estatCode)
{
    $view_controller = new ViewController();
    $editArr = $view_controller->xajaxObjCall($estatCode, 'JOB', 'editEmpStat');
    $objResponse = new xajaxResponse();
    $objResponse->addScript("document.frmJobTitle.txtEmpStatDesc.disabled = false;");
    $objResponse->addScript("document.frmJobTitle.txtEmpStatID.value = '" . $editArr[0][0] . "';");
    $objResponse->addScript("document.frmJobTitle.txtEmpStatDesc.value = '" . $editArr[0][1] . "';");
    $objResponse->addScript("document.frmJobTitle.txtEmpStatDesc.focus();");
    $objResponse->addScript("document.frmJobTitle.txtEmpStatDesc.selectAll();");
    $objResponse->addScript("document.getElementById('layerEmpStat').style.visibility='visible';");
    $objResponse->addAssign('buttonLayer', 'innerHTML', "<input type='button' value='" . $GLOBALS['lang_Common_Save'] . "' onclick='editFormData();'>");
    $objResponse->addAssign('status', 'innerHTML', '');
    return $objResponse->getXML();
}
コード例 #22
0
function do_include($aFormValues = "", $url = "")
{
    $objResponse = new xajaxResponse();
    if (RU == 1) {
        $objResponse->setCharEncoding('windows-1251');
    }
    // globalize form values
    if (is_array($aFormValues)) {
        foreach ($aFormValues as $key => $value) {
            Base::$aRequest[$key] = $value;
        }
    }
    // globalize url variables
    if ($url) {
        $url_string_array = parse_url($url);
        parse_str($url_string_array[query], $aUrl);
        Base::$aRequest = array_merge(Base::$aRequest, $aUrl);
    }
    Base::$oResponse = $objResponse;
    include_once SERVER_PATH . "/action_includer.php";
    return $objResponse->getXML();
}
コード例 #23
0
ファイル: process_alerts.inc.php プロジェクト: edt82/ona
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();
}
コード例 #24
0
ファイル: list_interfaces.inc.php プロジェクト: edt82/ona
function ws_display_list($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $images, $color, $style;
    $html = '';
    $js = '';
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Find the "tab" we're on
    $tab = $_SESSION['ona'][$form['form_id']]['tab'];
    // Build js to refresh this list
    $refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
    // If this is the display_host screen that called, add refresh for DNS records too
    if ($form['content_id'] == 'display_host_list_interfaces') {
        $refresh .= "xajax_window_submit('list_records', xajax.getFormValues('list_records_filter_form'), 'display_list');";
    }
    // If it's not a new query, load the previous query from the session
    // into $form and save the current page and filter in the session.
    // Also find/set the "page" we're viewing
    $page = 1;
    if ($form['page'] and is_numeric($form['page'])) {
        $form = array_merge($form, (array) $_SESSION['ona'][$form['form_id']][$tab]['q']);
        $_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
        $_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
    }
    // Calculate the SQL query offset (based on the page being displayed)
    $offset = $conf['search_results_per_page'] * ($page - 1);
    if ($offset == 0) {
        $offset = -1;
    }
    // Search results go in here
    $results = array();
    $count = 0;
    // Start building the "where" clause for the sql query to find the interfaces to display
    $where = "";
    $and = "";
    // HOST ID
    if ($form['host_id']) {
        $where .= $and . "host_id = " . $onadb->qstr($form['host_id']) . " OR id in (select interface_id from interface_clusters where host_id = " . $onadb->qstr($form['host_id']) . ")";
        $and = " AND ";
    }
    // Do the SQL Query
    $filter = '';
    if ($form['filter']) {
        $form['filter'] = ip_mangle($form['filter']);
        $filter = $and . ' ip_addr LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
    }
    list($status, $rows, $results) = db_get_records($onadb, 'interfaces', $where . $filter, "ip_addr ASC", $conf['search_results_per_page'], $offset);
    // If we got less than serach_results_per_page, add the current offset to it
    // so that if we're on the last page $rows still has the right number in it.
    if ($rows > 0 and $rows < $conf['search_results_per_page']) {
        $rows += $conf['search_results_per_page'] * ($page - 1);
    }
    // Re-Count only "internal" interfaces, not nat interfaces
    list($status, $rows, $records) = db_get_records($onadb, 'interfaces', 'nat_interface_id = \'0\' and ' . $where . $filter, "", 0);
    $count = $rows;
    $html .= <<<EOL
        <!-- Interface List -->
        <table id="{$form['form_id']}_interface_list" class="list-box" cellspacing="0" border="0" cellpadding="0">

            <!-- Table Header -->
            <tr>

                <td colspan="2" class="list-header" align="center" style="{$style['borderR']};">Interface</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Subnet</td>
                <td class="list-header" align="center" style="{$style['borderR']};">MAC</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Name</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Description</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Last Response</td>
                <td class="list-header" align="center">&nbsp;</td>
            </tr>
EOL;
    // Loop and display each record
    foreach ($results as $record) {
        // Get additional info about each host record //
        // Check if this interface has an external NAT
        unset($extnatint, $extnatdisplay, $extnatdisplay, $extnatsubdisplay);
        if ($record['nat_interface_id'] > 0) {
            list($status, $rows, $extnatint) = ona_get_interface_record(array('id' => $record['nat_interface_id']));
            // GDO: get the subnet object of the NATing interface, display it in both Interface and Subnet columns
            list($status, $rows, $extnatintsub) = ona_get_subnet_record(array('id' => $extnatint['subnet_id']));
            $extnatint['ip_addr'] = ip_mangle($extnatint['ip_addr'], 'dotted');
            //$extnatdisplay = "<span title='Interface is NATed to {$extnatint['ip_addr']}'> &nbsp;&nbsp;=> &nbsp;{$extnatint['ip_addr']}</span>";
            $extnatdisplay = "<span title='Interface is NATed to {$extnatint['ip_addr']} (on {$extnatintsub['name']})'> &nbsp;&nbsp;=> &nbsp;{$extnatint['ip_addr']}</span>";
            $extnatsubdisplay = " => <a title=\"View NATed subnet. ID: {$extnatintsub['id']}\"\n                                            class=\"nav\"\n                                            onClick=\"xajax_window_submit('work_space', 'xajax_window_submit(\\'display_subnet\\', \\'subnet_id=>{$extnatintsub['id']}\\', \\'display\\')');\"\n                                         >{$extnatintsub['name']}</a>";
        }
        // Check if this interface is an external NAT for another interface
        list($isnatstatus, $isnatrows, $isnat) = db_get_records($onadb, 'interfaces', "nat_interface_id = {$record['id']}", '', 0);
        // If the current interface is external NAT for another, dont display it in the list.
        if ($isnatrows > 0) {
            continue;
        }
        list($status, $intclusterrows, $intcluster) = db_get_records($onadb, 'interface_clusters', "interface_id = {$record['id']}");
        // Grab some info from the associated subnet record
        list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $record['subnet_id']));
        $record['ip_mask'] = $subnet['ip_mask'];
        $record['subnet_id'] = $subnet['id'];
        $record['subnet_description'] = $subnet['name'];
        // Convert IP and Netmask to a presentable format
        $record['ip_addr'] = ip_mangle($record['ip_addr'], 'dotted');
        $record['ip_mask'] = ip_mangle($record['ip_mask'], 'dotted');
        $record['ip_mask_cidr'] = ip_mangle($record['ip_mask'], 'cidr');
        if ($record['mac_addr']) {
            $record['mac_addr'] = mac_mangle($record['mac_addr']);
        }
        $record['description_short'] = truncate($record['description'], 40);
        // Escape data for display in html
        foreach (array_keys($record) as $key) {
            $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
        }
        // Format the date and colorize if its older than 2 months
        if ($record['last_response']) {
            $record['last_response_fmt'] = date($conf['date_format'], strtotime($record['last_response']));
            if (strtotime($record['last_response']) < strtotime('-2 month')) {
                $record['last_response_fmt'] = "<span style=\"color: red;\">" . $record['last_response_fmt'] . "</style>";
            }
        }
        $html .= <<<EOL
            <tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">

                <td nowrap="true" class="list-row" style="padding: 0px;" width="16px">
EOL;
        // Display cluster related information
        $clusterhtml = '&nbsp;';
        $clusterstyle = '';
        $clusterscript = '';
        if ($intclusterrows > 0) {
            $clusterstyle = 'font-weight: bold';
            $clusterscript = "onMouseOver=\"wwTT(this, event,\n                        'id', 'tt_interface_cluster_list_{$record['id']}',\n                        'type', 'velcro',\n                        'styleClass', 'wwTT_niceTitle',\n                        'direction', 'south',\n                        'javascript', 'xajax_window_submit(\\'tooltips\\', \\'tooltip=>interface_cluster_list,id=>tt_interface_cluster_list_{$record['id']},interface_id=>{$record['id']}\\');'\n                        );\"";
            $clusterhtml .= <<<EOL
                    <img src="{$images}/silk/sitemap.png" border="0" {$clusterscript} />
EOL;
        }
        $html .= $clusterhtml;
        $html .= <<<EOL
                </td>

                <td class="list-row">
EOL;
        // MP: Disabling the display_interface link. I dont think this will be needed
        if (1 < 0) {
            $html .= <<<EOL
                    <a title="View interface. ID: {$record['id']}"
                       class="nav"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_interface\\',\\'interface_id=>{$record['id']}\\', \\'display\\')');">
                        {$record['ip_addr']}
                        </a>
EOL;
        } else {
            $html .= "<span style='{$clusterstyle}' {$clusterscript}>{$record['ip_addr']}</span>";
        }
        $html .= <<<EOL
                    <span style="{$clusterstyle}" title="{$record['ip_mask']}">/{$record['ip_mask_cidr']}</span> {$extnatdisplay}
                </td>

                <td class="list-row" align="left">
                    <a title="View subnet. ID: {$subnet['id']}"
                       class="nav"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_subnet\\', \\'subnet_id=>{$subnet['id']}\\', \\'display\\')');"
                    >{$record['subnet_description']}</a> {$extnatsubdisplay}
                </td>

                <td class="list-row" align="right">
                    {$record['mac_addr']}&nbsp;
                </td>

                <td class="list-row" align="left">
                    {$record['name']}&nbsp;
                </td>

                <td class="list-row" align="left" title="{$record['description']}">
                    {$record['description_short']}&nbsp;
                </td>

                <td class="list-row" align="left" title="{$record['last_response']}">
                    {$record['last_response_fmt']}&nbsp;
                </td>

                <td class="list-row" align="right">
                    <form id="{$form['form_id']}_list_interface_{$record['id']}"
                        ><input type="hidden" name="interface_id" value="{$record['id']}"
                        ><input type="hidden" name="js" value="{$refresh}"
                    ></form>&nbsp;
EOL;
        if (auth('interface_modify')) {
            $html .= <<<EOL

                    <a title="Interface Menu"
                       id="int_menu_button_{$record['id']}"
                       class="act"
                       onmouseover="wwTT(this, event,
                                            'id', 'tt_quick_interface_menu_{$record['id']}',
                                            'type', 'velcro',
                                            'delay', 0,
                                            'styleClass', 'wwTT_int_menu',
                                            'lifetime', 1000,
                                            'direction', 'west',
                                            'javascript', 'xajax_window_submit(\\'tooltips\\', \\'tooltip=>quick_interface_menu,id=>tt_quick_interface_menu_{$record['id']},interface_id=>{$record['id']},ip_addr=>{$record['ip_addr']},orig_host=>{$record['host_id']},form_id=>{$form['form_id']}_list_interface_{$record['id']},subnet_id=>{$subnet['id']},natip=>{$record['nat_interface_id']}\\');'
                                           );"
                    ><img src="{$images}/silk/add.png" border="0"></a>&nbsp;
EOL;
        }
        if (auth('interface_modify')) {
            $html .= <<<EOL

                    <a title="Edit interface. ID: {$record['id']}"
                       class="act"
                       onClick="xajax_window_submit('edit_interface', xajax.getFormValues('{$form['form_id']}_list_interface_{$record['id']}'), 'editor');"
                    ><img src="{$images}/silk/page_edit.png" border="0"></a>&nbsp;
EOL;
        }
        if (auth('interface_del')) {
            $html .= <<<EOL

                    <a title="Delete interface"
                       class="act"
                       onClick="xajax_window_submit('edit_interface', xajax.getFormValues('{$form['form_id']}_list_interface_{$record['id']}'), 'delete');"
                    ><img src="{$images}/silk/delete.png" border="0"></a>&nbsp;
EOL;
        }
        $html .= <<<EOL
                </td>

            </tr>
EOL;
    }
    if ($count == 0 and $form['host_id'] and !$form['filter']) {
        $html .= <<<EOL
     <tr><td colspan="99" align="center" style="color: red;">Please add an interface to this host, or delete the host</td></tr>
EOL;
    }
    $html .= <<<EOL
    </table>
EOL;
    // Build page links if there are any
    $html .= get_page_links($page, $conf['search_results_per_page'], $count, $window_name, $form['form_id']);
    // Insert the new html into the content div specified
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("{$form['form_id']}_{$tab}_count", "innerHTML", "({$count})");
    $response->addAssign($form['content_id'], "innerHTML", $html);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
コード例 #25
0
ファイル: agent.server.php プロジェクト: ljhcj/IRISCC
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'astercrm_account');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'astercrm_account');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', $order, $divName, $ordering, '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } elseif ($type == "delete") {
        $arreglo =& Customer::getAllRecords($start, $limit, $order, $_SESSION['curuser']['groupid']);
        $content = '';
        foreach ($arreglo as $agents) {
            if ($agents['agent'] == $id) {
                continue;
            } else {
                $addstr = "\nagent => " . trim($agents['agent']) . ',' . trim($agents['password']) . ',' . trim($agents['name']);
            }
            $content .= $addstr;
        }
        $agentsfile = '/etc/asterisk/agents_astercc.conf';
        if ($fhandle = fopen($agentsfile, 'w')) {
            fwrite($fhandle, $content);
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $order, $divName, $ordering, $searchType);
            $objResponse = new xajaxResponse();
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } else {
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_delete"));
        }
    } else {
        $html = createGrid($numRows, $limit, $searchField, $searchContent, $order, $divName, $ordering, $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
コード例 #26
0
function _data_preset_rra_item_xajax_remove($preset_rra_id) {
	require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_update.php");
	require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_info.php");
	require_once(CACTI_BASE_PATH . "/lib/data_template/data_template_update.php");
	require_once(CACTI_BASE_PATH . "/lib/data_template/data_template_info.php");
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_update.php");
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php");

	$objResponse = new xajaxResponse();

	if (basename($_SERVER["PHP_SELF"]) == "presets_rra.php") {
		$preset_rra_item = api_data_preset_rra_item_get($preset_rra_id);
		$result = api_data_preset_rra_item_remove($preset_rra_id);
	}else if (basename($_SERVER["PHP_SELF"]) == "data_templates.php") {
		$preset_rra_item = api_data_template_rra_item_get($preset_rra_id);
		$result = api_data_template_rra_item_remove($preset_rra_id);
	}else if (basename($_SERVER["PHP_SELF"]) == "data_sources.php") {
		$preset_rra_item = api_data_source_rra_item_get($preset_rra_id);
		$result = api_data_source_rra_item_remove($preset_rra_id);
	}else{
		return false;
	}

	if ($result) {
		if (basename($_SERVER["PHP_SELF"]) == "presets_rra.php") {
			$num_items = sizeof(api_data_preset_rra_item_list($preset_rra_item["preset_rra_id"]));
		}else if (basename($_SERVER["PHP_SELF"]) == "data_templates.php") {
			$num_items = sizeof(api_data_template_rra_item_list($preset_rra_item["data_template_id"]));
		}else if (basename($_SERVER["PHP_SELF"]) == "data_sources.php") {
			$num_items = sizeof(api_data_source_rra_item_list($preset_rra_item["data_source_id"]));
		}

		/* if there are no rra items left, do not remove the row from the form but instead mark it as "new" */
		if ($num_items == 0) {
			$objResponse->addScript("remove_rra_item_last_row(\"$preset_rra_id\");");
		/* if there is at least one rra item left, visibly remove the row from the page */
		}else{
			$objResponse->addScript("remove_rra_item_row(\"$preset_rra_id\");");
		}
	}else{
		$objResponse->addAlert("Error removing RRA preset item!");
	}

	return $objResponse->getXML();
}
コード例 #27
0
 /**
  * This is the main communications engine of xajax. The engine handles all
  * incoming xajax requests, calls the apporiate PHP functions (or
  * class/object methods) and passes the XML responses back to the
  * Javascript response handler. If your RequestURI is the same as your Web
  * page then this function should be called before any headers or HTML has
  * been sent.
  */
 function processRequests()
 {
     $requestMode = -1;
     $sFunctionName = "";
     $bFoundFunction = true;
     $bFunctionIsCatchAll = false;
     $sFunctionNameForSpecial = "";
     $aArgs = array();
     $sPreResponse = "";
     $bEndRequest = false;
     $sResponse = "";
     $requestMode = $this->getRequestMode();
     if ($requestMode == -1) {
         return;
     }
     if ($requestMode == XAJAX_POST) {
         $sFunctionName = $_POST["xajax"];
         if (!empty($_POST["xajaxargs"])) {
             $aArgs = $_POST["xajaxargs"];
         }
     } else {
         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-cache, must-revalidate");
         header("Pragma: no-cache");
         $sFunctionName = $_GET["xajax"];
         if (!empty($_GET["xajaxargs"])) {
             $aArgs = $_GET["xajaxargs"];
         }
     }
     // Use xajax error handler if necessary
     if ($this->bErrorHandler) {
         $GLOBALS['xajaxErrorHandlerText'] = "";
         set_error_handler("xajaxErrorHandler");
     }
     if ($this->sPreFunction) {
         if (!$this->_isFunctionCallable($this->sPreFunction)) {
             $bFoundFunction = false;
             $objResponse = new xajaxResponse();
             $objResponse->addAlert("Unknown Pre-Function " . $this->sPreFunction);
             $sResponse = $objResponse->getXML();
         }
     }
     //include any external dependencies associated with this function name
     if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles)) {
         ob_start();
         include_once $this->aFunctionIncludeFiles[$sFunctionName];
         ob_end_clean();
     }
     if ($bFoundFunction) {
         $sFunctionNameForSpecial = $sFunctionName;
         if (!array_key_exists($sFunctionName, $this->aFunctions)) {
             if ($this->sCatchAllFunction) {
                 $sFunctionName = $this->sCatchAllFunction;
                 $bFunctionIsCatchAll = true;
             } else {
                 $bFoundFunction = false;
                 $objResponse = new xajaxResponse();
                 $objResponse->addAlert("Unknown Function {$sFunctionName}.");
                 $sResponse = $objResponse->getXML();
             }
         } else {
             if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) {
                 $bFoundFunction = false;
                 $objResponse = new xajaxResponse();
                 $objResponse->addAlert("Incorrect Request Type.");
                 $sResponse = $objResponse->getXML();
             }
         }
     }
     if ($bFoundFunction) {
         for ($i = 0; $i < sizeof($aArgs); $i++) {
             // If magic quotes is on, then we need to strip the slashes from the args
             if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
                 $aArgs[$i] = stripslashes($aArgs[$i]);
             }
             if (stristr($aArgs[$i], "<xjxobj>") != false) {
                 $aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]);
             } else {
                 if (stristr($aArgs[$i], "<xjxquery>") != false) {
                     $aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]);
                 } else {
                     if ($this->bDecodeUTF8Input) {
                         $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
                     }
                 }
             }
         }
         if ($this->sPreFunction) {
             $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
             if (is_array($mPreResponse) && $mPreResponse[0] === false) {
                 $bEndRequest = true;
                 $sPreResponse = $mPreResponse[1];
             } else {
                 $sPreResponse = $mPreResponse;
             }
             if (is_a($sPreResponse, "xajaxResponse")) {
                 $sPreResponse = $sPreResponse->getXML();
             }
             if ($bEndRequest) {
                 $sResponse = $sPreResponse;
             }
         }
         if (!$bEndRequest) {
             if (!$this->_isFunctionCallable($sFunctionName)) {
                 $objResponse = new xajaxResponse();
                 $objResponse->addAlert("The Registered Function {$sFunctionName} Could Not Be Found.");
                 $sResponse = $objResponse->getXML();
             } else {
                 if ($bFunctionIsCatchAll) {
                     $aArgs = array($sFunctionNameForSpecial, $aArgs);
                 }
                 $sResponse = $this->_callFunction($sFunctionName, $aArgs);
             }
             if (is_a($sResponse, "xajaxResponse")) {
                 $sResponse = $sResponse->getXML();
             }
             if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
                 $objResponse = new xajaxResponse();
                 $objResponse->addAlert("No XML Response Was Returned By Function {$sFunctionName}.");
                 $sResponse = $objResponse->getXML();
             } else {
                 if ($sPreResponse != "") {
                     $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
                     $sNewResponse->loadXML($sPreResponse);
                     $sNewResponse->loadXML($sResponse);
                     $sResponse = $sNewResponse->getXML();
                 }
             }
         }
     }
     $sContentHeader = "Content-type: text/xml;";
     if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
         $sContentHeader .= " charset=" . $this->sEncoding;
     }
     header($sContentHeader);
     if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) {
         $sErrorResponse = new xajaxResponse();
         $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
         if ($this->sLogFile) {
             $fH = @fopen($this->sLogFile, "a");
             if (!$fH) {
                 $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
             } else {
                 fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
                 fclose($fH);
             }
         }
         $sErrorResponse->loadXML($sResponse);
         $sResponse = $sErrorResponse->getXML();
     }
     if ($this->bCleanBuffer) {
         while (@ob_end_clean()) {
         }
     }
     print $sResponse;
     if ($this->bErrorHandler) {
         restore_error_handler();
     }
     if ($this->bExitAllowed) {
         exit;
     }
 }
コード例 #28
0
ファイル: worktime.server.php プロジェクト: ljhcj/IRISCC
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'worktimes');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($type == "delete") {
        $row = Customer::getRecordByField('worktime_id', $id, 'worktimepackage_worktimes');
        if ($row['id'] != '') {
            $objResponse->addAlert($locate->Translate("this worktime in one or more package, can not delete"));
            return $objResponse->getXML();
        }
        $res = Customer::deleteRecord($id, 'worktimes');
        if ($res) {
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $order, $divName, $ordering, $searchType);
            $objResponse = new xajaxResponse();
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } else {
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_delete"));
        }
    } else {
        $html = createGrid($numRows, $limit, $searchField, $searchContent, $order, $divName, $ordering, $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
コード例 #29
0
function do_objectsstart($fid, $confid, $editnum)
{
    global $db, $phpEx, $phpbb_root_path, $user;
    $objResponse = new xajaxResponse();
    //如果已经超时,刷新页面,进入登陆
    if (!$user->data['is_registered']) {
        $objResponse->addScript("location.reload();");
        return $objResponse->getXML();
    }
    $sql = 'SELECT formula.*,sys_formula.* FROM ' . CONFRATERNITY_FORMULA . ' formula   
				LEFT JOIN 	' . SYSTEM_FORMULA . '	sys_formula	ON(formula.formulaid=sys_formula.formulaid)
				  WHERE formula.buildid=' . $confid . ' AND formula.cityid=' . $user->data['last_place'] . ' AND 
				  formula.formulaid=' . $fid;
    $result = $db->sql_query($sql);
    if ($fo = $db->sql_fetchrow($result)) {
        if ($fo['object1'] != '') {
            $object1 = unserialize($fo['object1']);
        } else {
            $object1 = '';
        }
        if ($fo['object2'] != '') {
            $object2 = unserialize($fo['object2']);
        } else {
            $object2 = '';
        }
        if ($fo['object3'] != '') {
            $object3 = unserialize($fo['object3']);
        } else {
            $object3 = '';
        }
        if ($fo['object4'] != '') {
            $object4 = unserialize($fo['object4']);
        } else {
            $object4 = '';
        }
        if ($fo['skill1'] != '') {
            $skill1 = unserialize($fo['skill1']);
        } else {
            $skill1 = '';
        }
        if ($fo['skill2'] != '') {
            $skill2 = unserialize($fo['skill2']);
        } else {
            $skill2 = '';
        }
        //判断钱最多制作的数量
        $numcoin = 0;
        if ($fo['price_g'] > 0) {
            $numcoin = floor($user->data['u_gold_coin'] / $fo['price_g']);
        }
        if ($fo['price_s'] > 0) {
            $snum = floor($user->data['u_silver_coin'] / $fo['price_s']);
            if ($numcoin > 0) {
                if ($snum < $numcoin) {
                    $numcoin = $snum;
                }
            } else {
                $numcoin = $snum;
            }
        }
        if ($fo['price_c'] > 0) {
            $cnum = floor($user->data['u_copper_coin'] / $fo['price_c']);
            if ($numcoin > 0) {
                if ($cnum < $numcoin) {
                    $numcoin = $cnum;
                }
            } else {
                $numcoin = $cnum;
            }
        }
    }
    $db->sql_freeresult($result);
    //判断用户是否有这个技能
    if ($fo['skill1'] != '') {
        $sql = 'SELECT skill_id,skill_lv FROM ' . USERS_SKILLS . '  
				  WHERE user_id=' . $user->data['user_id'] . ' AND skill_id=' . $skill1['skid'] . '  AND skill_lv>=' . $skill1['sklv'];
        $result = $db->sql_query($sql);
        if (!($ff = $db->sql_fetchrow($result))) {
            return $objResponse->getXML();
        }
        $db->sql_freeresult($result);
    }
    if ($fo['skill2'] != '') {
        $sql = 'SELECT skill_id,skill_lv FROM ' . USERS_SKILLS . '  
				  WHERE user_id=' . $user->data['user_id'] . ' AND skill_id=' . $skill2['skid'] . '  AND skill_lv>=' . $skill2['sklv'];
        $result = $db->sql_query($sql);
        if (!($ff = $db->sql_fetchrow($result))) {
            return $objResponse->getXML();
        }
        $db->sql_freeresult($result);
    }
    //判断物品数量
    $strsql = '(';
    if ($object1 != '') {
        $strsql .= $object1['obid'];
    }
    if ($object2 != '') {
        $strsql .= ',' . $object2['obid'];
    }
    if ($object3 != '') {
        $strsql .= ',' . $object3['obid'];
    }
    if ($object4 != '') {
        $strsql .= ',' . $object4['obid'];
    }
    $strsql .= ')';
    $sql = 'SELECT objectid,object_num FROM ' . USER_BAG . '  
				  WHERE user_id=' . $user->data['user_id'] . ' AND objectid IN ' . $strsql;
    $result = $db->sql_query($sql);
    $obs = array();
    $obnum1 = $obnum2 = $obnum3 = $obnum4 = 0;
    while ($row = $db->sql_fetchrow($result)) {
        if ($object1 != '' && $row['objectid'] == $object1['obid']) {
            $obnum1 = floor($row['object_num'] / $object1['obnum']);
        }
        if ($object2 != '' && $row['objectid'] == $object2['obid']) {
            $obnum2 = floor($row['object_num'] / $object2['obnum']);
        }
        if ($object3 != '' && $row['objectid'] == $object3['obid']) {
            $obnum3 = floor($row['object_num'] / $object3['obnum']);
        }
        if ($object4 != '' && $row['objectid'] == $object4['obid']) {
            $obnum4 = floor($row['object_num'] / $object4['obnum']);
        }
    }
    $db->sql_freeresult($result);
    $onum = $obnum1;
    if ($obnum2 > 0 && $obnum2 < $onum) {
        $onum = $obnum2;
    }
    if ($obnum3 > 0 && $obnum3 < $onum) {
        $onum = $obnum3;
    }
    if ($obnum4 > 0 && $obnum4 < $onum) {
        $onum = $obnum4;
    }
    // onum为原材料可以做的最大物品数,$numcoin为钱可以做的最大物品数
    if ($numcoin < $onum) {
        $onum = $numcoin;
    }
    //最终的最大数量为$editnum
    if ($editnum > $onum) {
        $editnum = $onum;
    }
    //开始处理数据,扣用户的钱,减物品,添加物品,或者更新物品
    $db->sql_transaction('begin');
    //扣钱
    $sql = 'UPDATE ' . USER_EXINFO . ' SET u_copper_coin=u_copper_coin-' . $fo['price_c'] * $editnum . ',u_silver_coin=u_silver_coin-' . $fo['price_s'] * $editnum . '  ,u_gold_coin=u_gold_coin-' . $fo['price_g'] * $editnum . '  WHERE user_id=' . $user->data['user_id'];
    $db->sql_query($sql);
    //减物品
    if ($object1['obid'] > 0) {
        $sql = 'UPDATE ' . USER_BAG . ' SET object_num=object_num-' . $object1['obnum'] * $editnum . ' 
					WHERE objectid= ' . $object1['obid'] . ' AND user_id=' . $user->data['user_id'];
        $db->sql_query($sql);
    }
    if ($object2 != '' && $object2['obid'] > 0) {
        $sql = 'UPDATE ' . USER_BAG . ' SET object_num=object_num-' . $object2['obnum'] * $editnum . ' 
					WHERE objectid= ' . $object2['obid'] . ' AND user_id=' . $user->data['user_id'];
        $db->sql_query($sql);
    }
    if ($object3 != '' && $object3['obid'] > 0) {
        $sql = 'UPDATE ' . USER_BAG . ' SET object_num=object_num-' . $object3['obnum'] * $editnum . ' 
					WHERE objectid= ' . $object3['obid'] . ' AND user_id=' . $user->data['user_id'];
        $db->sql_query($sql);
    }
    if ($object4 != '' && $object4['obid'] > 0) {
        $sql = 'UPDATE ' . USER_BAG . ' SET object_num=object_num-' . $object4['obnum'] * $editnum . ' 
					WHERE objectid= ' . $object4['obid'] . ' AND user_id=' . $user->data['user_id'];
        $db->sql_query($sql);
    }
    $sql = 'DELETE FROM ' . USER_BAG . ' 	WHERE object_num=0 AND user_id=' . $user->data['user_id'];
    $db->sql_query($sql);
    $db->sql_transaction('commit');
    $sql = 'SELECT objectid,object_num FROM ' . USER_BAG . '  
				  WHERE user_id=' . $user->data['user_id'] . ' AND objectid=' . $fo['objectid'];
    $result = $db->sql_query($sql);
    if ($row = $db->sql_fetchrow($result)) {
        $sql = 'UPDATE ' . USER_BAG . ' SET object_num=object_num+' . $editnum . ' 
					WHERE objectid= ' . $fo['objectid'] . ' AND user_id=' . $user->data['user_id'];
        $db->sql_query($sql);
    } else {
        /********************************************************************************************** 
         *
         * 判断背包,UPDATE还是INSERT ,另外生成displayorder
         *
         ***********************************************************************************************/
        $sql = 'SELECT objectid,object_num,displayorder FROM ' . USERS_BAG . ' WHERE user_id = ' . $user->data['user_id'] . ' ORDER BY displayorder ';
        $result = $db->sql_query($sql);
        $goodnum = 0;
        $i = 1;
        $display = 0;
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['displayorder'] != $i && $display == 0) {
                $display = $i;
            }
            $i++;
            $goodnum++;
        }
        $db->sql_freeresult($result);
        $sql = 'INSERT INTO ' . USER_BAG . '(objectid,user_id,object_num,,displayorder)
				VALUES(' . $fo['objectid'] . ',' . $user->data['user_id'] . ',' . $editnum . ',' . $display . ')';
        $db->sql_query($sql);
    }
    $db->sql_freeresult($result);
    //初始化界面
    $objResponse->addAssign("domax", "disabled", false);
    $objResponse->addAssign("objectnum", "disabled", true);
    $objResponse->addAssign("objectnum", "value", 0);
    $objResponse->addAssign("max", "value", 0);
    $objResponse->addAssign("doit", "disabled", true);
    return $objResponse->getXML();
}
コード例 #30
0
function submitForm($elems, $doneFunc = 'AjaxFormObj.checkDone', $errFunc = 'AjaxFormObj.checkError')
{
    global $lbl, $txt, $users_extra_fields;
    $auth = R3AuthInstance::get();
    $fieldDescr = array('app_code' => array(MISSING_FIELD => _("Il campo 'applicazione' e' obbligatorio"), INVALID_FIELD => _("Il campo 'applicazione' contiene caratteri non validi. Solo lettere e numeri sono accettati"), PK_ERROR => _("Il campo 'codice' immesso esiste gia'")), 'app_name' => array(MISSING_FIELD => _("Il campo 'nome' e' obbligatorio")));
    // print_r($elems);
    $elems = AjaxSplitArray($elems);
    // print_r($elems);
    $objResponse = new xajaxResponse();
    /** User extra field for the common section */
    $extra_fields = $auth->getConfigValue('USER_MANAGER', 'EXTRA_FIELDS', array());
    if (isset($users_extra_fields)) {
        $extra_fields = array_merge($extra_fields, $users_extra_fields);
    }
    $error = array();
    try {
        $errors = checkReq($extra_fields, $elems);
        if (!empty($errors)) {
            $errorMsg = implode('\\n', $errors);
            throw new Exception($errorMsg);
        }
        if ($auth->passwordStatus < 0 && $elems['us_password'] == '') {
            throw new Exception('Password must be set');
        }
        /** Extra fields in user table */
        $extras = array();
        foreach ($extra_fields as $key => $val) {
            if (!isset($val['inistorage']) && !isset($val['kind'])) {
                if (isset($elems[$key])) {
                    $extras[$key] = $elems[$key];
                }
            }
        }
        /** password check */
        if ($elems['us_password'] != '' && $elems['us_password'] != $elems['us_password2']) {
            throw new Exception('Invalid password');
        }
        if ($elems['us_password'] != '') {
            $auth->setParam('us_password', $elems['us_password'], true);
        }
        foreach ($extras as $key => $val) {
            $auth->setParam($key, $val, true);
        }
        /** Extra fields in user table */
        foreach ($extra_fields as $key => $val) {
            if (isset($val['inistorage']) && !isset($val['kind'])) {
                if (isset($elems[$key])) {
                    $auth->setConfigValue($val['inistorage'][0], $val['inistorage'][1], $elems[$key]);
                }
            }
        }
    } catch (EPermissionDenied $e) {
        $error['element'][] = '';
        $error['message'][] = $e->getMessage();
    } catch (EDatabaseError $e) {
        $error['element'][] = '';
        $error['message'][] = "Database error: " . $e->getMessage();
    } catch (EInputError $e) {
        $error['element'][] = $e->getField();
        if (isset($fieldDescr[$e->getField()][$e->getCode()])) {
            $error['message'][] = $fieldDescr[$e->getField()][$e->getCode()];
        } else {
            $error['message'][] = $e->getMessage();
        }
    } catch (Exception $e) {
        $error['element'][] = '';
        //$error['message'][] = 'Generic error: ' . $e->getMessage();
        $error['message'][] = $e->getMessage();
    }
    // Action
    if (count($error) > 0) {
        $errText = $txt['err_store_failed'] . "\n - " . implode("\n - ", $error['message']);
        $objResponse->addScriptCall($errFunc, $errText, $error['element'][0]);
    } else {
        $objResponse->addScriptCall($doneFunc);
    }
    return $objResponse->getXML();
}