本文整理汇总了PHP中dbError函数的典型用法代码示例。如果您正苦于以下问题:PHP dbError函数的具体用法?PHP dbError怎么用?PHP dbError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateUserProfile
/**
* UpdateUserProfile
*
* @param $user_id
* @param $pass1
* @param $hideOffline
* @param $theme
* @param $language
*/
function UpdateUserProfile($user_id, $pass1, $hideOffline, $theme, $language)
{
global $cfg, $db;
if (empty($hideOffline) || $hideOffline == "" || !isset($hideOffline)) {
$hideOffline = "0";
}
// update values
$rec = array();
if ($pass1 != "") {
$rec['password'] = md5($pass1);
AuditAction($cfg["constants"]["update"], $cfg['_PASSWORD']);
}
$sql = "select * from tf_users where user_id = " . $db->qstr($user_id);
$rs = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
$rec['hide_offline'] = $hideOffline;
$rec['theme'] = $theme;
$rec['language_file'] = $language;
$sql = $db->GetUpdateSQL($rs, $rec);
if ($sql != "") {
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
// flush session-cache
cacheFlush($cfg["user"]);
}
}
示例2: login
function login($email, $password)
{
global $db;
// Prepare e-mail address
$email = $db->escape_string($email);
$email = strtolower($email);
$password = $db->escape_string($password);
$email_part = explode("@", $email);
$username = $email_part[0];
$domain = $email_part[1];
// Check e-mail address
$sql = "SELECT `" . DBC_USERS_ID . "`, `" . DBC_USERS_PASSWORD . "` FROM `" . DBT_USERS . "` WHERE `" . DBC_USERS_USERNAME . "` = '{$username}' AND `" . DBC_USERS_DOMAIN . "` = '{$domain}' LIMIT 1;";
if (!($result = $db->query($sql))) {
dbError($db->error);
}
if ($result->num_rows === 1) {
$userdata = $result->fetch_array(MYSQLI_ASSOC);
$uid = $userdata[DBC_USERS_ID];
$password_hash = $userdata[DBC_USERS_PASSWORD];
// Check password
if (crypt($password, $password_hash) === $password_hash) {
// Password is valid, start a logged-in user session
$this->loggedin = true;
$_SESSION['uid'] = $uid;
$_SESSION['email'] = $email;
return true;
} else {
// Password is invalid
return false;
}
} else {
// User could not be found
return false;
}
}
示例3: modCookieInfo
/**
* Modify Cookie Host Information
*
* @param $cid
* @param $newCookie
*/
function modCookieInfo($cid, $newCookie)
{
global $db;
$sql = "UPDATE tf_cookies SET host=" . $db->qstr($newCookie["host"]) . ", data=" . $db->qstr($newCookie["data"]) . " WHERE cid=" . $db->qstr($cid);
$db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}
示例4: GetRSSLinks
/**
* get rss links
*
* @return array
*/
function GetRSSLinks()
{
global $cfg, $db;
$link_array = array();
$sql = "SELECT rid, url FROM tf_rss ORDER BY rid";
$link_array = $db->GetAssoc($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
return $link_array;
}
示例5: dbQuery
function dbQuery($query, $link = 'db_link'){
global $link;
$$link = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
if ($$link) mysql_select_db(DB_DATABASE);
$result = mysql_query($query, $$link) or dbError($query, mysql_errno(), mysql_error());
return $result;
}
示例6: Delete
public static function Delete($lang)
{
global $DB;
$DB->Query("SELECT * FROM `" . self::$table . "` WHERE `SID` = '" . sSql($lang) . "'");
if (!$DB->numRows()) {
return false;
} else {
$sql = "DELETE FROM `" . self::$table . "` WHERE `SID` = '" . sSql($lang) . "';";
if ($DB->Query($sql)) {
return true;
} else {
dbError($DB->Error());
return false;
}
}
}
示例7: _maintenanceDatabasePrune
/**
* prune database
*/
function _maintenanceDatabasePrune()
{
global $cfg, $db;
// output
$this->_outputMessage("pruning database...\n");
$this->_outputMessage("table : tf_log\n");
// Prune LOG
$this->_count = 0;
$testTime = time() - $cfg['days_to_keep'] * 86400;
// 86400 is one day in seconds
$sql = "delete from tf_log where time < " . $db->qstr($testTime);
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
$this->_count += $db->Affected_Rows();
unset($result);
$testTime = time() - $cfg['minutes_to_keep'] * 60;
$sql = "delete from tf_log where time < " . $db->qstr($testTime) . " and action=" . $db->qstr($cfg["constants"]["hit"]);
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
$this->_count += $db->Affected_Rows();
unset($result);
/* done */
if ($this->_count > 0) {
$this->_outputMessage("deleted entries from tf_log : " . $this->_count . "\n");
} else {
$this->_outputMessage("no entries deleted.\n");
}
$this->_outputMessage("prune database done.\n");
}
示例8: Delete
public static function Delete($ID)
{
global $DB;
$DB->Query("SELECT * FROM `" . self::$table . "` WHERE `ID` = '" . sSql($ID) . "'");
if (!$DB->numRows()) {
return false;
} else {
$sql1 = "DELETE FROM `" . self::$table . "` WHERE `ID` = '" . sSql($ID) . "';";
$sql2 = "DELETE FROM `" . self::$table_lang . "` WHERE `CATALOG_TYPE_ID` = '" . sSql($ID) . "';";
if ($DB->Query($sql1) and $DB->Query($sql2)) {
return true;
} else {
dbError($DB->Error());
return false;
}
}
}
示例9: getDownloadFtpLogUsers
function getDownloadFtpLogUsers($srchFile, $logNumber = "")
{
global $cfg, $db, $dlLog;
$userlist = array();
$userRenamer = array();
//xferlog or xferlog.0 (last month)
//$ftplog = '/var/log/proftpd/xferlog'.$logNumber;
$ftplog = "/var/log/pure-ftpd/stats_transfer{$logNumber}.log";
if (!is_file($ftplog)) {
return array();
}
//Search in Log (for old or external log insert, todo)
$srchFile = str_replace($cfg["path"], '', $srchFile);
//Search in cached db log array
foreach ($dlLog as $row) {
if ($row->file == $srchFile) {
$userlist[$row->user_id] = htmlentities(substr($row->user_id, 0, 3), ENT_QUOTES);
}
}
if (count($userlist) > 0) {
return $userlist;
}
if (!file_exists($ftplog)) {
return $userlist;
}
$userRenamer["root"] = "epsylon3";
$cmdLog = "cat {$ftplog}|" . $cfg["bin_grep"] . ' ' . tfb_shellencode(str_replace(' ', '_', $srchFile));
//.'|'.$cfg["bin_grep"]." -o -E ' r (.*) ftp'"
$dlInfos = trim(@shell_exec($cmdLog));
if ($dlInfos) {
$ftpusers = explode("\n", $dlInfos);
foreach ($ftpusers as $key => $value) {
/* PROFTPD
$value=substr($value,4);
$time=strtotime(substr($value,0,20));
$value=substr($value,21);
$lineWords=explode(' ',$value);
$hostname=$lineWords[1];
$size=0+($lineWords[2]);
$username=$lineWords[count($lineWords)-5];
$complete=$lineWords[count($lineWords)-1]; */
/* pure-ftpd (stats:/var/log/pure-ftpd/stats_transfer.log) */
$lineWords = explode(' ', $value);
$time = 0 + $lineWords[0];
$username = $lineWords[2];
$hostname = $lineWords[3];
$complete = str_replace("D", "c", $lineWords[4]);
$size = 0.0 + $lineWords[5];
//die( "<pre>$size-$complete-$hostname-$username-$time\n$value\n</pre>");
if ($complete == "c") {
//rename user ?
if (array_key_exists($username, $userRenamer)) {
$username = $userRenamer[$username];
}
if (!array_key_exists($username, $userlist)) {
$srchAction = "File Download (FTP)";
$db->Execute("INSERT INTO tf_log (user_id,file,action,ip,ip_resolved,user_agent,time)" . " VALUES (" . $db->qstr($username) . "," . $db->qstr($srchFile) . "," . $db->qstr($srchAction) . "," . $db->qstr('FTP') . "," . $db->qstr($hostname) . "," . $db->qstr('FTP') . "," . $time . ")");
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}
$userlist[$username] = substr($username, 0, 3);
}
}
}
return $userlist;
}
示例10: deleteProfileInfo
/**
* Delete Profile Information
*
* @param $pid
*/
function deleteProfileInfo($pid)
{
global $db;
$sql = "DELETE FROM tf_trprofiles WHERE id=" . $db->qstr($pid);
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}
示例11: GetMessage
/**
* Get Message data in an array
*
* @param $mid
* @return array
*/
function GetMessage($mid)
{
global $cfg, $db;
$sql = "select from_user, message, ip, time, isnew, force_read from tf_messages where mid=" . $db->qstr($mid) . " and to_user=" . $db->qstr($cfg["user"]);
$rtnValue = $db->GetRow($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
return $rtnValue;
}
示例12: getComments
function getComments($dbconn, $xmlDoc, $post_id)
{
$parentNode = $xmlDoc->createElement('comments');
$query = "select * from comments where post_id = " . dbEsc($post_id) . " order by date DESC";
$result = mysql_query($query);
if (!$result) {
$statusNode = $xmlDoc->createElement('getComments_status', $query);
dbError($xmlDoc, $parentNode, mysql_error());
} else {
$statusNode = $xmlDoc->createElement('query_status', 'success');
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$query2 = "SELECT username FROM users WHERE user_id = " . $row['user_id'];
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
$theChildNode = $xmlDoc->createElement('comment');
$theChildNode->setAttribute('username', $row2['username']);
$theChildNode->setAttribute('comment', $row['comment']);
$theChildNode->setAttribute('date', $row['date']);
$parentNode->appendChild($theChildNode);
}
$parentNode->appendChild($statusNode);
return $parentNode;
}
示例13: instance_getData
/**
* method to get data from URL -- uses timeout and user agent
*
* @param $get_url
* @param $get_referer
* @return string
*/
function instance_getData($get_url, $get_referer = "")
{
global $cfg, $db;
// set fields
$this->url = $get_url;
$this->referer = $get_referer;
// (re)set state
$this->state = SIMPLEHTTP_STATE_NULL;
// (re-)set some vars
$this->cookie = "";
$this->request = "";
$this->responseBody = "";
$this->responseHeaders = array();
$this->gotResponseLine = false;
$this->status = "";
$this->errstr = "";
$this->errno = 0;
$this->socket = 0;
/**
* array of URL component parts for use in raw HTTP request
* @param array $domain
*/
$domain = parse_url($this->url);
if (empty($domain) || empty($domain['scheme']) || $domain['scheme'] != 'http' && $domain['scheme'] != 'https' || empty($domain['host'])) {
$this->state = SIMPLEHTTP_STATE_ERROR;
$msg = "Error fetching " . $this->url . ". This is not a valid HTTP/HTTPS URL.";
array_push($this->messages, $msg);
AuditAction($cfg["constants"]["error"], $msg);
return $data = "";
}
$secure = $domain['scheme'] == 'https';
if ($secure && !$this->_canTLS()) {
$this->state = SIMPLEHTTP_STATE_ERROR;
$msg = "Error fetching " . $this->url . ". PHP does not have module OpenSSL, which is needed for HTTPS.";
array_push($this->messages, $msg);
AuditAction($cfg["constants"]["error"], $msg);
return $data = "";
}
// get-command
if (!array_key_exists("path", $domain)) {
$domain["path"] = "/";
}
$this->getcmd = $domain["path"];
if (!array_key_exists("query", $domain)) {
$domain["query"] = "";
}
// append the query string if included:
$this->getcmd .= !empty($domain["query"]) ? "?" . $domain["query"] : "";
// Check to see if cookie required for this domain:
$sql = "SELECT c.data AS data FROM tf_cookies AS c LEFT JOIN tf_users AS u ON ( u.uid = c.uid ) WHERE u.user_id = " . $db->qstr($cfg["user"]) . " AND c.host = " . $db->qstr($domain['host']);
$this->cookie = $db->GetOne($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
if (!array_key_exists("port", $domain)) {
$domain["port"] = $secure ? 443 : 80;
}
// Fetch the data using fsockopen():
$this->socket = @fsockopen(($secure ? 'tls://' : '') . $domain["host"], $domain["port"], $this->errno, $this->errstr, $this->timeout);
if (!empty($this->socket)) {
// Write the outgoing HTTP request using cookie info
// Standard HTTP/1.1 request looks like:
//
// GET /url/path/example.php HTTP/1.1
// Host: example.com
// Accept: */*
// Accept-Language: en-us
// User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0
// Connection: Close
// Cookie: uid=12345;pass=asdfasdf;
//
//$this->request = "GET " . ($this->httpVersion=="1.1" ? $this->getcmd : $this->url ). " HTTP/" . $this->httpVersion ."\r\n";
$this->request = "GET " . $this->_fullURLEncode($this->getcmd) . " HTTP/" . $this->httpVersion . "\r\n";
$this->request .= !empty($this->referer) ? "Referer: " . $this->referer . "\r\n" : "";
$this->request .= "Accept: */*\r\n";
$this->request .= "Accept-Language: en-us\r\n";
$this->request .= "User-Agent: " . $this->userAgent . "\r\n";
$this->request .= "Host: " . $domain["host"] . "\r\n";
if ($this->httpVersion == "1.1") {
$this->request .= "Connection: Close\r\n";
}
if (!empty($this->cookie)) {
$this->request .= "Cookie: " . $this->cookie . "\r\n";
}
$this->request .= "\r\n";
// Send header packet information to server
fputs($this->socket, $this->request);
// socket-options
stream_set_timeout($this->socket, $this->timeout);
// meta-data
$info = stream_get_meta_data($this->socket);
// Get response headers:
while (!$info['timed_out'] && ($line = @fgets($this->socket, 500000))) {
//.........这里部分代码省略.........
示例14: resetOwner
/**
* reset Owner
*
* @param $transfer
* @return string
*/
function resetOwner($transfer)
{
global $cfg, $db, $transfers;
// log entry has expired so we must renew it
$rtnValue = "n/a";
if (file_exists($cfg["transfer_file_path"] . $transfer . ".stat")) {
$sf = new StatFile($transfer);
if (IsUser($sf->transferowner)) {
$rtnValue = $sf->transferowner;
} else {
$rtnValue = GetSuperAdmin();
}
/* no owner found, so the super admin will now own it */
// add entry to the log
$sql = "INSERT INTO tf_log (user_id,file,action,ip,ip_resolved,user_agent,time)" . " VALUES (" . $db->qstr($rtnValue) . "," . $db->qstr($transfer) . "," . $db->qstr($cfg["constants"]["reset_owner"]) . "," . $db->qstr($cfg['ip']) . "," . $db->qstr($cfg['ip_resolved']) . "," . $db->qstr($cfg['user_agent']) . "," . $db->qstr(time()) . ")";
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}
$transfers['owner'][$transfer] = $rtnValue;
return $rtnValue;
}
示例15: changeUserLevel
/**
* Change User Level
*
* @param $user_id
* @param $level
*/
function changeUserLevel($user_id, $level)
{
global $db;
$sql = "select * from tf_users where user_id = " . $db->qstr($user_id);
$rs = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
$rec = array('user_level' => $level);
$sql = $db->GetUpdateSQL($rs, $rec);
$result = $db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}