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


PHP db_write函数代码示例

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


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

示例1: pray_sav

function pray_sav($p, $o, $res = '')
{
    list($p, $o) = ajxp($res, $p, $o);
    //echo $p.'-'.$o.'-'.$res;
    //$r=db_read('ummo/pray/1511');
    $r = msql_read('', 'ummo_pray_1', '', '');
    if ($r) {
        foreach ($r as $k => $v) {
            if ($v[0] == $p && $v[1] == $o) {
                $id = $k;
            }
        }
    }
    if ($id) {
        unset($r[$id]);
    } else {
        $r[] = array($p, $o, 1);
    }
    msql_modif('users', 'ummo_pray_1', $r, $dfb, 'arr', '');
    db_write('ummo/pray/1511', $r);
    //if(!$id)modif_vars('users','ummo_pray_1',array($p,$o,1),'push');
    //else modif_vars('users','ummo_pray_1',array($id=>array($p,$o,0)),'mdf');
    $ret = pray_build($p, $o, $r);
    return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:25,代码来源:pray.php

示例2: clearAIMLByFileName

/**
 * Function clearAIMLByFileName
 *
 * * @param $filename
 * @return string
 */
function clearAIMLByFileName($filename)
{
    global $dbn, $bot_id, $dbConn;
    $sql = "delete from `aiml` where `filename` like '{$filename}' and `bot_id` = {$bot_id};";
    $affectedRows = db_write($sql, null, false, __FILE__, __FUNCTION__, __LINE__);
    $msg = "<br/><strong>AIML categories cleared for file {$filename}!</strong><br />";
    return $msg;
}
开发者ID:ramdesh,项目名称:Program-O,代码行数:14,代码来源:clear.php

示例3: api_oauth2_grant_tokens_purge

function api_oauth2_grant_tokens_purge()
{
    $then = api_oauth2_grant_tokens_min_age();
    # TO DO: purge caches - iterate over all the keys?
    # (20121103/straup)
    $sql = "DELETE FROM OAuth2GrantTokens WHERE created <= {$then}";
    $rsp = db_write($sql);
    return $rsp;
}
开发者ID:whosonfirst,项目名称:flamework-api,代码行数:9,代码来源:lib_api_oauth2_grant_tokens.php

示例4: dots_search_extras_remove_dot

function dots_search_extras_remove_dot(&$dot)
{
    $enc_id = AddSlashes($dot['id']);
    $sql = "DELETE FROM DotsSearchExtras WHERE dot_id='{$enc_id}'";
    $rsp = db_write($sql);
    if ($rsp['ok']) {
        $cache_key = "dots_search_extras_{$dot['id']}";
        cache_unset($cache_key);
    }
    return $rsp;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:11,代码来源:lib_dots_search_extras.php

示例5: delAIML

/**
 * Function delAIML
 *
 * * @param $id
 * @return string
 */
function delAIML($id)
{
    if ($id != "") {
        $sql = "DELETE FROM `aiml` WHERE `id` = '{$id}' LIMIT 1";
        $affectedRows = db_write($sql, null, false, __FILE__, __FUNCTION__, __LINE__);
        if ($affectedRows == 0) {
            $msg = 'Error AIML couldn\'t be deleted - no changes made.</div>';
        } else {
            $msg = 'AIML has been deleted.';
        }
    } else {
        $msg = 'Error AIML couldn\'t be deleted - no changes made.';
    }
    return $msg;
}
开发者ID:stillfinder,项目名称:Program-O,代码行数:21,代码来源:editAiml.php

示例6: delete_room

	function delete_room($id){

		$room = db_single(db_fetch("SELECT * FROM choose_rooms WHERE id=$id"));
		$parent	= db_single(db_fetch("SELECT * FROM choose_rooms WHERE room_1=$id OR room_2=$id"));

		if ($room[room_1]) return 0;
		if ($room[room_2]) return 0;

		db_write("DELETE FROM choose_rooms WHERE id=$id");

		if ($parent[id]){
			db_write("UPDATE choose_rooms SET room_1=0 WHERE id=$parent[id] AND room_1=$id");
			db_write("UPDATE choose_rooms SET room_2=0 WHERE id=$parent[id] AND room_2=$id");
		}

		return 1;
	}
开发者ID:NobisPete,项目名称:choose,代码行数:17,代码来源:purge.php

示例7: delete_room

function delete_room($id)
{
    $room = db_single(mysql_query("SELECT * FROM choose_rooms WHERE id=" . $id));
    $parent = db_single(mysql_query("SELECT * FROM choose_rooms WHERE room_1=" . $id . " OR room_2=" . $id));
    if ($room['room_1']) {
        return 0;
    }
    if ($room['room_2']) {
        return 0;
    }
    db_write("DELETE FROM choose_rooms WHERE id=" . $id);
    if ($parent['id']) {
        db_write("UPDATE choose_rooms SET room_1=0 WHERE id=" . $parent['id'] . " AND room_1=" . $id);
        db_write("UPDATE choose_rooms SET room_2=0 WHERE id=" . $parent['id'] . " AND room_2=" . $id);
    }
    return 1;
}
开发者ID:Digitalbil,项目名称:Choose,代码行数:17,代码来源:purge.php

示例8: authorization

function authorization()
{
    global $body;
    global $mod;
    global $curr;
    global $modules;
    // ---------------- init ---------------- //
    $login = '';
    $pass = '';
    $auth = array('id' => 0, 'desc' => '', 'state' => 1, 'perm' => '', 'sid' => 0);
    //  state:
    // 1  - sess exists
    // 2  - ok
    // 4  - sess not exists
    // 8  - user for sess_id not exists
    // ------------------------------------ identificate organization ------------------------------------ //
    $auth['org'] = 0;
    $auth['org_desc'] = 'Добро пожаловать в Pyur CRM-Framework';
    // ---- DoS filter --------------------------------------------------------------------------- //
    /*
        // -- `IP` filter -- //
      $remote_addr = explode('.', (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'0.0.0.0') );
      $remote_addr = $remote_addr[0] * 16777216 + $remote_addr[1] * 65536 + $remote_addr[2] * 256 + $remote_addr[3];
    
      //$result = db_read('login_ip', array('date', 'count'), '`ip` = '.$remote_addr);
      $result = db_read(array('table'=>'login_ip', 'col'=>array('date', 'count'), 'where'=>'`ip` = '.$remote_addr));
      if ($result) {
        //$db = mysql_fetch_array($result, MYSQL_ASSOC);
        $auth_ip_date = datesqltime($result['date']);
        $auth_ip_count = $result['count'];
    
        if ($auth_ip_count > 15)  $auth['state'] = 16;
        }
      else {
        $result = db_write(array('table'=>'login_ip', 'set'=>array('ip' => $remote_addr, 'count' => 0));
        $auth_ip_date = $curr['time'];
        $auth_ip_count = 0;
        }
    */
    // ------------------------------------ read COOKIE ------------------------------------- //
    if (cookieb('bdsx_sid')) {
        $sess = db_read(array('table' => 'sess', 'col' => array('id', 'user', 'ip', 'ua'), 'where' => array('`sid` = \'' . cookieh('bdsx_sid') . '\'', '`stat` = 0')));
        if ($sess) {
            $auth['sid'] = $sess['id'];
            $ua = substr($_SERVER['HTTP_USER_AGENT'], 0, 512);
            $ipn = inet_pton($_SERVER['REMOTE_ADDR']);
            $set = array();
            $set['datel'] = $curr['datetime'];
            if ($sess['ip'] != $ipn) {
                $set['ip'] = $ipn;
            }
            if ($sess['ua'] != $ua) {
                $set['ua'] = $ua;
            }
            db_write(array('table' => 'sess', 'set' => $set, 'where' => '`sid` = \'' . cookieh('bdsx_sid') . '\''));
            $sess = $sess['user'];
        } else {
            header("Cache-Control: no-cache, must-revalidate");
            header("Expires: Thu, 17 Apr 1991 12:00:00 GMT");
            setcookie('bdsx_sid', '', time() - 60 * 60, '/');
            $auth['state'] = 4;
        }
    } else {
        $auth['state'] = 4;
    }
    // --------------------- hardwired (embedded), not DB-MySQL users: --------------------------- //
    if ($auth['state'] == 1 && $sess > 65503) {
        include 'l/hu.php';
        if (isset($harduser[$sess - 65504])) {
            $auth['id'] = $sess;
            $auth['desc'] = $harduser[$sess - 65504]['desc'];
            $auth['perm'] = $harduser[$sess - 65504]['perm'];
            $auth['state'] = 2;
        } else {
            $auth['state'] = 8;
        }
    }
    // --------------------------------- read & check `user` --------------------------------------- //
    /*
      if ($auth['state'] == 1) {
    
        $user = db_read(array('table' => array('user', 'user_cat'),
                              'col' => array('user`.`name',
                                             'user_cat`.`perm',
                                             ),
                              'where' => array('`user`.`id` = \''.$sess.'\'',
                                               '`user_cat`.`id` = `user`.`cat`',
                                               ),
                              ));
    
        if ($user) {
          $auth['id'] = $sess;
          $auth['desc'] = $user['name'];
          $auth['perm'] = $user['perm'];
          $auth['state'] = 2;
          }
        else {
          $auth['state'] = 8;
          }
        }
//.........这里部分代码省略.........
开发者ID:pyur,项目名称:site,代码行数:101,代码来源:auth.php

示例9: intval

if ($_POST['done']) {
    $id = intval($_POST['id']);
    db_update('choose_rooms', array('blurb' => AddSlashes($_POST['blurb']), 'text_1' => AddSlashes($_POST['text_1']), 'text_2' => AddSlashes($_POST['text_2'])), "id={$id}");
    header("location: edit.php?id={$id}&done=1");
    exit;
}
#
# delete room?
#
if ($_POST['delete']) {
    $id = intval($_POST['id']);
    $room = db_single(mysql_query("SELECT * FROM choose_rooms WHERE id={$id}"));
    $parent = db_single(mysql_query("SELECT * FROM choose_rooms WHERE room_1={$id} OR room_2={$id}"));
    db_write("DELETE FROM choose_rooms WHERE id={$id}");
    db_write("UPDATE choose_rooms SET room_1=0 WHERE room_1={$id}");
    db_write("UPDATE choose_rooms SET room_2=0 WHERE room_2={$id}");
    header("location: edit.php?id={$parent['id']}");
    exit;
}
#
# get info for display
#
$room_id = intval($_GET['id']);
$room = db_single(mysql_query("SELECT * FROM choose_rooms WHERE id={$room_id}"));
$parent = db_single(mysql_query("SELECT * FROM choose_rooms WHERE room_1={$room_id} OR room_2={$room_id}"));
if (!$room['id']) {
    include 'header.txt';
    print "error: room {$room_id} not found";
    include 'footer.txt';
    exit;
}
开发者ID:Digitalbil,项目名称:Choose,代码行数:31,代码来源:edit.php

示例10: parseAIML

/**
 * Function parseAIML
 *
 * * @param $fn
 * @param      $aimlContent
 * @param bool $from_zip
 * @return string
 */
function parseAIML($fn, $aimlContent, $from_zip = false)
{
    global $dbConn, $post_vars;
    if (empty($aimlContent)) {
        return "File {$fn} was empty!";
    }
    global $dbConn, $debugmode, $bot_id, $charset;
    $fileName = basename($fn);
    $success = false;
    $topic = '';
    #Clear the database of the old entries
    $sql = "DELETE FROM `aiml`  WHERE `filename` = :filename AND bot_id = :bot_id";
    if (isset($post_vars['clearDB'])) {
        $params = array(':filename' => $fileName, ':bot_id' => $bot_id);
        $affectedRows = db_write($sql, $params, false, __FILE__, __FUNCTION__, __LINE__);
    }
    $myBot_id = isset($post_vars['bot_id']) ? $post_vars['bot_id'] : $bot_id;
    # Read new file into the XML parser
    $sql = 'insert into `aiml` (`id`, `bot_id`, `aiml`, `pattern`, `thatpattern`, `template`, `topic`, `filename`) values
    (NULL, :bot_id, :aiml, :pattern, :that, :template, :topic, :fileName);';
    # Validate the incoming document
    /*******************************************************/
    /*       Set up for validation from a common DTD       */
    /*       This will involve removing the XML and        */
    /*       AIML tags from the beginning of the file      */
    /*       and replacing them with our own tags          */
    /*******************************************************/
    $validAIMLHeader = '<?xml version="1.0" encoding="[charset]"?>
<!DOCTYPE aiml PUBLIC "-//W3C//DTD Specification Version 1.0//EN" "http://www.program-o.com/xml/aiml.dtd">
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1">';
    $validAIMLHeader = str_replace('[charset]', $charset, $validAIMLHeader);
    $aimlTagStart = stripos($aimlContent, '<aiml', 0);
    $aimlTagEnd = strpos($aimlContent, '>', $aimlTagStart) + 1;
    $aimlFile = $validAIMLHeader . substr($aimlContent, $aimlTagEnd);
    $tmpDir = _UPLOAD_PATH_ . 'tmp' . DIRECTORY_SEPARATOR;
    if (!file_exists($tmpDir)) {
        mkdir($tmpDir, 0755);
    }
    save_file(_UPLOAD_PATH_ . 'tmp/' . $fileName, $aimlFile);
    try {
        libxml_use_internal_errors(true);
        $xml = new DOMDocument();
        $xml->loadXML($aimlFile);
        $aiml = new SimpleXMLElement($xml->saveXML());
        $rowCount = 0;
        $_SESSION['failCount'] = 0;
        $params = array();
        if (!empty($aiml->topic)) {
            foreach ($aiml->topic as $topicXML) {
                # handle any topic tag(s) in the file
                $topicAttributes = $topicXML->attributes();
                $topic = $topicAttributes['name'];
                foreach ($topicXML->category as $category) {
                    $fullCategory = $category->asXML();
                    $pattern = trim($category->pattern);
                    $pattern = str_replace("'", ' ', $pattern);
                    $pattern = IS_MB_ENABLED ? mb_strtoupper($pattern) : strtoupper($pattern);
                    $that = $category->that;
                    $that = IS_MB_ENABLED ? mb_strtoupper($that) : strtoupper($that);
                    $template = $category->template->asXML();
                    $template = str_replace('<template>', '', $template);
                    $template = str_replace('</template>', '', $template);
                    $template = trim($template);
                    # Strip CRLF and LF from category (Windows/mac/*nix)
                    $aiml_add = str_replace(array("\r\n", "\n"), '', $fullCategory);
                    $params[] = array(':bot_id' => $bot_id, ':aiml' => $aiml_add, ':pattern' => $pattern, ':that' => $that, ':template' => $template, ':topic' => $topic, ':fileName' => $fileName);
                }
            }
        }
        if (!empty($aiml->category)) {
            foreach ($aiml->category as $category) {
                $fullCategory = $category->asXML();
                $pattern = trim($category->pattern);
                $pattern = str_replace("'", ' ', $pattern);
                $pattern = IS_MB_ENABLED ? mb_strtoupper($pattern) : strtoupper($pattern);
                $that = $category->that;
                $template = $category->template->asXML();
                //strip out the <template> tags, as they aren't needed
                $template = substr($template, 10);
                $tLen = strlen($template);
                $template = substr($template, 0, $tLen - 11);
                $template = trim($template);
                # Strip CRLF and LF from category (Windows/mac/*nix)
                $aiml_add = str_replace(array("\r\n", "\n"), '', $fullCategory);
                $params[] = array(':bot_id' => $bot_id, ':aiml' => $aiml_add, ':pattern' => $pattern, ':that' => $that, ':template' => $template, ':topic' => '', ':fileName' => $fileName);
            }
        }
        if (!empty($params)) {
            $rowCount = db_write($sql, $params, true, __FILE__, __FUNCTION__, __LINE__);
            $success = $rowCount !== false ? true : false;
        }
        $msg = $from_zip === true ? '' : "Successfully added {$fileName} to the database.<br />\n";
//.........这里部分代码省略.........
开发者ID:stillfinder,项目名称:Program-O,代码行数:101,代码来源:upload.php

示例11: explode



	#
	# activate an old outfit?
	#

	if ($_GET['activate']){

		list($id, $code) = explode('-', $_GET['activate']);

		foreach ($avatars as $row){

			if ($id == $row['id'] && $code == $row['code']){

				db_write("UPDATE glitchmash_avatars SET is_active=0 WHERE player_tsid='$tsid_enc'");
				db_write("UPDATE glitchmash_avatars SET is_active=1 WHERE player_tsid='$tsid_enc' AND id=$row[id]");

				header("location: /you/?active=1");
				exit;
			}
		}
	}


	#
	# fetch all clothing rows
	#

	if (count($clothing)){
		$clothing_ids = implode(',', array_keys($clothing));
		$clothing = array();
开发者ID:power7714,项目名称:glitch-mash,代码行数:29,代码来源:you.php

示例12: time

		'date_updated'	=> time(),
		'details'	=> AddSlashes(serialize($avatar)),
	);

	$hash2 = $hash;
	unset($hash2['date_added']);

	db_insert_dupe('glitchmash_avatars', $hash, $hash2);


	#
	# mark only the latest one as active
	#

	$tsid_enc = AddSlashes($cfg['user']['tsid']);

	list($latest_id) = db_list(db_fetch("SELECT id FROM glitchmash_avatars WHERE player_tsid='$tsid_enc' ORDER BY date_updated DESC LIMIT 1"));

	$latest_id = intval($latest_id);

	db_write("UPDATE glitchmash_avatars SET is_active=0 WHERE player_tsid='$tsid_enc' AND id!=$latest_id");
	db_write("UPDATE glitchmash_avatars SET is_active=1 WHERE player_tsid='$tsid_enc' AND id=$latest_id");


	#
	# done
	#

	header("location: /you/?imported=1");
	exit;
?>
开发者ID:power7714,项目名称:glitch-mash,代码行数:31,代码来源:import.php

示例13: updateWordCensor

function updateWordCensor()
{
    global $dbConn, $template, $msg, $request_vars;
    $word_to_censor = trim($request_vars['word_to_censor']);
    $replace_with = trim($request_vars['replace_with']);
    $id = trim($request_vars['censor_id']);
    if ($id == "" || $word_to_censor == "" || $replace_with == "") {
        $msg = '<div id="errMsg">There was a problem editing the replace_with - no changes made.</div>';
    } else {
        $sql = 'UPDATE `wordcensor` SET `word_to_censor` = :word_to_censor,`replace_with`= :replace_with WHERE `censor_id`= :id LIMIT 1';
        $params = array(':word_to_censor' => $word_to_censor, ':replace_with' => $replace_with, ':id' => $id);
        $result = db_write($sql, $params, false, __FILE__, __FUNCTION__, __LINE__);
        if ($result > 0) {
            $msg = '<div id="successMsg">Correction edited.</div>';
        } else {
            $msg = '<div id="errMsg">There was a problem editing the replace_with - no changes made.</div>';
        }
    }
}
开发者ID:lordmatt,项目名称:Program-O,代码行数:19,代码来源:wordcensor.php

示例14: fopen

<?php

include_once $_SERVER["DOCUMENT_ROOT"] . "/include/common/dbpara.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/common/enum_values.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/modules/dbconnect.php";
$f = fopen("dblogin.sql", "r");
$sql = "";
while (!feof($f)) {
    $sql .= fgets($f);
}
$sqls = explode(";", $sql);
//var_dump($sqls);
fclose($f);
foreach ($sqls as $sql2) {
    if (strlen($sql2) > 0) {
        db_write($sql2, null);
    }
}
echo "SQL INIT OK";
开发者ID:Takeya-Yuki-Studio,项目名称:Yuki-Auth-Login,代码行数:19,代码来源:database.php

示例15: fopen

<?php

include_once $_SERVER["DOCUMENT_ROOT"] . "/include/common/mui.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/modules/dbconnect.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/common/dbpara.php";
$path = $_SERVER["DOCUMENT_ROOT"] . "/install/SqlScripts/" . $_POST["key"] . "." . $_POST["value"] . ".sql";
$f = fopen($path, "r");
$sql = "";
while (!feof($f)) {
    $sql .= fgets($f);
}
$sqls = explode(";", $sql);
//var_dump($sqls);
fclose($f);
$ret = true;
foreach ($sqls as $sql2) {
    if (strlen($sql2) > 0) {
        //echo $sql2;
        $ret = db_write($sql2, null);
    }
}
if ($ret === true) {
    echo install::installok;
} else {
    echo install::installfail;
}
开发者ID:Takeya-Yuki-Studio,项目名称:Yuki-Auth-Login,代码行数:26,代码来源:modprobe.php


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