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


PHP DBexecute函数代码示例

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


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

示例1: login

 public static function login($login, $password)
 {
     try {
         self::setDefault();
         self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
         if (!self::$data) {
             throw new Exception();
         }
         if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
             error(_('GUI access disabled.'));
             throw new Exception();
         }
         if (empty(self::$data['url'])) {
             self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
         }
         if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
             CProfile::init();
             CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
             CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
             CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
             CProfile::flush();
         }
         // remove guest session after successful login
         DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
         zbx_setcookie('zbx_sessionid', self::$data['sessionid'], self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0);
         return true;
     } catch (Exception $e) {
         self::setDefault();
         return false;
     }
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:class.cwebuser.php

示例2: zbx_session_start

function zbx_session_start($userid, $name, $password)
{
    $sessionid = md5(time() . $password . $name . rand(0, 10000000));
    zbx_setcookie('zbx_sessionid', $sessionid);
    DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES (' . zbx_dbstr($sessionid) . ',' . $userid . ',' . time() . ',' . ZBX_SESSION_ACTIVE . ')');
    return $sessionid;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:7,代码来源:perm.inc.php

示例3: login

 /**
  * Tries to login a user and populates self::$data on success.
  *
  * @param string $login			user login
  * @param string $password		user password
  *
  * @throws Exception if user cannot be logged in
  *
  * @return bool
  */
 public static function login($login, $password)
 {
     try {
         self::setDefault();
         self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
         if (!self::$data) {
             throw new Exception();
         }
         if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
             error(_('GUI access disabled.'));
             throw new Exception();
         }
         if (empty(self::$data['url'])) {
             self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
         }
         $result = (bool) self::$data;
         if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
             CProfile::init();
             CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
             CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
             CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
             $result &= CProfile::flush();
         }
         // remove guest session after successful login
         $result &= DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
         if ($result) {
             self::setSessionCookie(self::$data['sessionid']);
             add_audit_ext(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, self::$data['userid'], '', null, null, null);
         }
         return $result;
     } catch (Exception $e) {
         self::setDefault();
         return false;
     }
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:45,代码来源:CWebUser.php

示例4: disable_httptest

function disable_httptest($httptestid)
{
    $result = DBexecute('UPDATE httptest SET status=' . HTTPTEST_STATUS_DISABLED . ' WHERE httptestid=' . zbx_dbstr($httptestid));
    $itemids = array();
    $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid=' . zbx_dbstr($httptestid));
    while ($itemid = Dbfetch($items_db)) {
        $itemids[] = $itemid['itemid'];
    }
    $items_db = DBselect('SELECT hsi.itemid' . ' FROM httpstep hs,httpstepitem hsi' . ' WHERE hs.httpstepid=hsi.httpstepid' . ' AND hs.httptestid=' . zbx_dbstr($httptestid));
    while ($itemid = Dbfetch($items_db)) {
        $itemids[] = $itemid['itemid'];
    }
    $result &= DBexecute('UPDATE items SET status=' . ITEM_STATUS_DISABLED . ' WHERE ' . dbConditionInt('itemid', $itemids));
    return $result;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:15,代码来源:httptest.inc.php

示例5: delete_template_triggers

function delete_template_triggers($hostid, $templateids = null, $unlink_mode = false)
{
    zbx_value2array($templateids);
    $triggers = get_triggers_by_hostid($hostid);
    while ($trigger = DBfetch($triggers)) {
        if ($trigger['templateid'] == 0) {
            continue;
        }
        if ($templateids != null) {
            $db_tmp_hosts = get_hosts_by_triggerid($trigger["templateid"]);
            $tmp_host = DBfetch($db_tmp_hosts);
            if (!uint_in_array($tmp_host["hostid"], $templateids)) {
                continue;
            }
        }
        if ($unlink_mode) {
            if (DBexecute('UPDATE triggers SET templateid=0 WHERE triggerid=' . $trigger['triggerid'])) {
                info('Trigger "' . $trigger["description"] . '" unlinked');
            }
        } else {
            delete_trigger($trigger["triggerid"]);
        }
    }
    return TRUE;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:25,代码来源:triggers.inc.php

示例6: get_host_by_applicationid

            $go_result = true;
            $host = get_host_by_applicationid($httptest_data['applicationid']);
            add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCENARIO, _('Scenario') . ' [' . $httptest_data['name'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . ']' . _('Scenario disabled'));
        }
    }
    show_messages($go_result, _('Scenario disabled'), null);
} elseif ($_REQUEST['go'] == 'clean_history' && isset($_REQUEST['group_httptestid'])) {
    $go_result = false;
    $group_httptestid = $_REQUEST['group_httptestid'];
    foreach ($group_httptestid as $id) {
        if (!($httptest_data = get_httptest_by_httptestid($id))) {
            continue;
        }
        if (delete_history_by_httptestid($id)) {
            $go_result = true;
            DBexecute('UPDATE httptest SET nextcheck=0 WHERE httptestid=' . $id);
            $host = get_host_by_applicationid($httptest_data['applicationid']);
            add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCENARIO, _('Scenario') . ' [' . $httptest_data['name'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . ']' . _('History cleared'));
        }
    }
    show_messages($go_result, _('History cleared'), null);
} elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['group_httptestid'])) {
    $go_result = API::WebCheck()->delete($_REQUEST['group_httptestid']);
    show_messages($go_result, _('Scenario deleted'), null);
}
if ($_REQUEST['go'] != 'none' && isset($go_result) && $go_result) {
    $url = new CUrl();
    $path = $url->getPath();
    insert_js('cookie.eraseArray("' . $path . '")');
}
show_messages();
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:httpconf.php

示例7: massUpdate


//.........这里部分代码省略.........
         }
         if (isset($data['useip'])) {
             $sql_set[] = 'useip=' . $data['useip'];
         }
         if (isset($data['dns'])) {
             $sql_set[] = 'dns=' . zbx_dbstr($data['dns']);
         }
         if (isset($data['ip'])) {
             $sql_set[] = 'ip=' . zbx_dbstr($data['ip']);
         }
         if (isset($data['useipmi'])) {
             $sql_set[] = 'useipmi=' . $data['useipmi'];
         }
         if (isset($data['ipmi_port'])) {
             $sql_set[] = 'ipmi_port=' . $data['ipmi_port'];
         }
         if (isset($data['ipmi_authtype'])) {
             $sql_set[] = 'ipmi_authtype=' . $data['ipmi_authtype'];
         }
         if (isset($data['ipmi_privilege'])) {
             $sql_set[] = 'ipmi_privilege=' . $data['ipmi_privilege'];
         }
         if (isset($data['ipmi_username'])) {
             $sql_set[] = 'ipmi_username=' . zbx_dbstr($data['ipmi_username']);
         }
         if (isset($data['ipmi_password'])) {
             $sql_set[] = 'ipmi_password=' . zbx_dbstr($data['ipmi_password']);
         }
         if (isset($data['ipmi_ip'])) {
             $sql_set[] = 'ipmi_ip=' . zbx_dbstr($data['ipmi_ip']);
         }
         if (!empty($sql_set)) {
             $sql = 'UPDATE hosts SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $hostids);
             $result = DBexecute($sql);
             if (isset($data['status'])) {
                 update_host_status($hostids, $data['status']);
             }
         }
         // }}} UPDATE HOSTS PROPERTIES
         // UPDATE HOSTGROUPS LINKAGE {{{
         if (isset($data['groups']) && !is_null($data['groups'])) {
             $data['groups'] = zbx_toArray($data['groups']);
             $host_groups = CHostGroup::get(array('hostids' => $hostids));
             $host_groupids = zbx_objectValues($host_groups, 'groupid');
             $new_groupids = zbx_objectValues($data['groups'], 'groupid');
             $groups_to_add = array_diff($new_groupids, $host_groupids);
             if (!empty($groups_to_add)) {
                 $result = self::massAdd(array('hosts' => $hosts, 'groups' => zbx_toObject($groups_to_add, 'groupid')));
                 if (!$result) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t add group');
                 }
             }
             $groupids_to_del = array_diff($host_groupids, $new_groupids);
             if (!empty($groupids_to_del)) {
                 $result = self::massRemove(array('hostids' => $hostids, 'groupids' => $groupids_to_del));
                 if (!$result) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove group');
                 }
             }
         }
         // }}} UPDATE HOSTGROUPS LINKAGE
         $data['templates_clear'] = isset($data['templates_clear']) ? zbx_toArray($data['templates_clear']) : array();
         $cleared_templateids = array();
         foreach ($hostids as $hostid) {
             foreach ($data['templates_clear'] as $tpl) {
                 $result = unlink_template($hostid, $tpl['templateid'], false);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.chost.php

示例8: deleteMedia

 /**
  * Delete User Medias
  *
  * <code>
  * $media_data = array(
  * 	*string 'userid => 'User ID',
  * 	array 'mediaids' => array('Media ID', 'Media ID', ...)
  * );
  * </code>
  *
  * @static
  * @param array $media_data 
  * @return boolean
  */
 public static function deleteMedia($media_data)
 {
     $sql = 'DELETE FROM media WHERE userid=' . $media_data['userid'] . ' AND ' . DBcondition('mediaid', $media_data['mediaids']);
     $result = DBexecute($sql);
     if ($result) {
         return true;
     } else {
         self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error');
         return false;
     }
 }
开发者ID:phedders,项目名称:zabbix,代码行数:25,代码来源:class.cuser.php

示例9: delete_host_profile_ext

function delete_host_profile_ext($hostids)
{
    zbx_value2array($hostids);
    $result = DBexecute('DELETE FROM hosts_profiles_ext WHERE ' . DBcondition('hostid', $hostids));
    return $result;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:6,代码来源:hosts.inc.php

示例10: elseif

            }
        } elseif (isset($_REQUEST['test'])) {
            show_messages($login, _('LDAP login successful'), _('LDAP login was not successful'));
        }
    }
} elseif ($config['authentication_type'] == ZBX_AUTH_HTTP) {
    if (isset($_REQUEST['save'])) {
        // get groups wich use this authentication method
        $result = DBfetch(DBselect('SELECT COUNT(g.usrgrpid) AS cnt_usrgrp FROM usrgrp g WHERE g.gui_access=' . GROUP_GUI_ACCESS_INTERNAL));
        if ($result['cnt_usrgrp'] > 0) {
            info(_n('There is "%1$d" group with Internal GUI access.', 'There are "%1$d" groups with Internal GUI access.', $result['cnt_usrgrp']));
        }
        if (update_config($config)) {
            // reset all sessions
            if ($isAuthenticationTypeChanged) {
                DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr($USER_DETAILS['sessionid']));
            }
            $isAuthenticationTypeChanged = false;
            add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, _('Authentication method changed to HTTP'));
            show_message(_('Authentication method changed to HTTP'));
        } else {
            show_error_message(_('Cannot change authentication method to HTTP'));
        }
    }
}
show_messages();
/*
 * Display
 */
$data = array('form_refresh' => get_request('form_refresh'), 'config' => $config, 'is_authentication_type_changed' => $isAuthenticationTypeChanged, 'user' => get_request('user', $USER_DETAILS['alias']), 'user_password' => get_request('user_password', ''), 'user_list' => null, 'change_bind_password' => get_request('change_bind_password'));
// get tab title
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:authentication.php

示例11: delete_expression

function delete_expression($expressionids)
{
    zbx_value2array($expressionids);
    $sql = 'DELETE FROM expressions WHERE ' . DBcondition('expressionid', $expressionids);
    return DBexecute($sql);
}
开发者ID:rennhak,项目名称:zabbix,代码行数:6,代码来源:regexp.inc.php

示例12: delete

 /**
  * Delete data from DB.
  *
  * Example:
  * DB::delete('applications', array('applicationid'=>array(1, 8, 6)));
  * DELETE FROM applications WHERE applicationid IN (1, 8, 6)
  *
  * DB::delete('applications', array('applicationid'=>array(1), 'templateid'=array(10)));
  * DELETE FROM applications WHERE applicationid IN (1) AND templateid IN (10)
  *
  * @param string $table
  * @param array  $wheres pair of fieldname => fieldvalues
  * @param bool   $use_or
  *
  * @return bool
  */
 public static function delete($table, $wheres, $use_or = false)
 {
     if (empty($wheres) || !is_array($wheres)) {
         self::exception(self::DBEXECUTE_ERROR, _s('Cannot perform delete statement on table "%1$s" without where condition.', $table));
     }
     $table_schema = self::getSchema($table);
     $sqlWhere = array();
     foreach ($wheres as $field => $values) {
         if (!isset($table_schema['fields'][$field]) || is_null($values)) {
             self::exception(self::DBEXECUTE_ERROR, _s('Incorrect field "%1$s" name or value in where statement for table "%2$s".', $field, $table));
         }
         $values = zbx_toArray($values);
         sort($values);
         // sorting ids to prevent deadlocks when two transactions depends from each other
         $sqlWhere[] = dbConditionString($field, $values);
     }
     $sql = 'DELETE FROM ' . $table . ' WHERE ' . implode($use_or ? ' OR ' : ' AND ', $sqlWhere);
     if (!DBexecute($sql)) {
         self::exception(self::DBEXECUTE_ERROR, _s('SQL statement execution has failed "%1$s"', $sql));
     }
     return true;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:38,代码来源:DB.php

示例13: get_dbid

function get_dbid($table, $field)
{
    // PGSQL on transaction failure on all queries returns false..
    global $DB;
    if ($DB['TYPE'] == ZBX_DB_POSTGRESQL && $DB['TRANSACTIONS'] && !$DB['TRANSACTION_NO_FAILED_SQLS']) {
        return 0;
    }
    $found = false;
    $min = 0;
    $max = ZBX_DB_MAX_ID;
    do {
        $dbSelect = DBselect('SELECT i.nextid FROM ids i WHERE i.table_name=' . zbx_dbstr($table) . ' AND i.field_name=' . zbx_dbstr($field));
        if (!$dbSelect) {
            return false;
        }
        $row = DBfetch($dbSelect);
        if (!$row) {
            $row = DBfetch(DBselect('SELECT MAX(' . $field . ') AS id FROM ' . $table . ' WHERE ' . $field . ' BETWEEN ' . $min . ' AND ' . $max));
            if (!$row || $row['id'] == 0) {
                DBexecute("INSERT INTO ids (table_name,field_name,nextid) VALUES ('{$table}','{$field}',{$min})");
            } else {
                DBexecute("INSERT INTO ids (table_name,field_name,nextid) VALUES ('{$table}','{$field}'," . $row['id'] . ')');
            }
            continue;
        } else {
            $ret1 = $row['nextid'];
            if (bccomp($ret1, $min) < 0 || !bccomp($ret1, $max) < 0) {
                DBexecute('DELETE FROM ids WHERE table_name=' . zbx_dbstr($table) . ' AND field_name=' . zbx_dbstr($field));
                continue;
            }
            $sql = 'UPDATE ids SET nextid=nextid+1 WHERE table_name=' . zbx_dbstr($table) . ' AND field_name=' . zbx_dbstr($field);
            DBexecute($sql);
            $row = DBfetch(DBselect('SELECT i.nextid FROM ids i WHERE i.table_name=' . zbx_dbstr($table) . ' AND i.field_name=' . zbx_dbstr($field)));
            if (!$row || is_null($row['nextid'])) {
                // should never be here
                continue;
            } else {
                $ret2 = $row['nextid'];
                if (bccomp(bcadd($ret1, 1, 0), $ret2, 0) == 0) {
                    $found = true;
                }
            }
        }
    } while (false == $found);
    return $ret2;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:46,代码来源:db.inc.php

示例14: elseif

    if (isset($_REQUEST['operations'][$edit_operationid])) {
        $_REQUEST['new_operation'] = $_REQUEST['operations'][$edit_operationid];
        $_REQUEST['new_operation']['id'] = $edit_operationid;
        $_REQUEST['new_operation']['action'] = 'update';
    }
} elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasRequest('g_actionid')) {
    $result = true;
    $enable = getRequest('go') == 'activate';
    $status = $enable ? ACTION_STATUS_ENABLED : ACTION_STATUS_DISABLED;
    $statusName = $enable ? 'enabled' : 'disabled';
    $actionIds = array();
    $updated = 0;
    DBstart();
    $dbActions = DBselect('SELECT a.actionid' . ' FROM actions a' . ' WHERE ' . dbConditionInt('a.actionid', $_REQUEST['g_actionid']));
    while ($row = DBfetch($dbActions)) {
        $result &= DBexecute('UPDATE actions' . ' SET status=' . zbx_dbstr($status) . ' WHERE actionid=' . zbx_dbstr($row['actionid']));
        if ($result) {
            $actionIds[] = $row['actionid'];
        }
        $updated++;
    }
    $result = DBend($result);
    if ($result) {
        add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions [' . implode(',', $actionIds) . '] ' . $statusName);
    }
    $messageSuccess = $enable ? _n('Action enabled', 'Actions enabled', $updated) : _n('Action disabled', 'Actions disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable action', 'Cannot enable actions', $updated) : _n('Cannot disable action', 'Cannot disable actions', $updated);
    show_messages($result, $messageSuccess, $messageFailed);
    clearCookies($result);
} elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_actionid'])) {
    $goResult = API::Action()->delete($_REQUEST['g_actionid']);
开发者ID:hujingguang,项目名称:work,代码行数:31,代码来源:actionconf.php

示例15: update_action_status

function update_action_status($actionid, $status)
{
    return DBexecute("update actions set status={$status} where actionid={$actionid}");
}
开发者ID:rennhak,项目名称:zabbix,代码行数:4,代码来源:actions.inc.php


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