本文整理匯總了PHP中DBSafe函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBSafe函數的具體用法?PHP DBSafe怎麽用?PHP DBSafe使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBSafe函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getObject
/**
* Title
*
* Description
*
* @access public
*/
function getObject($name) {
$rec=SQLSelectOne("SELECT * FROM objects WHERE TITLE LIKE '".DBSafe($name)."'");
if ($rec['ID']) {
include_once(DIR_MODULES.'objects/objects.class.php');
$obj=new objects();
$obj->id=$rec['ID'];
$obj->loadObject($rec['ID']);
return $obj;
}
return 0;
}
示例2: subscribeToEvent
function subscribeToEvent($module_name, $event_name, $filter_details = '')
{
$rec = SQLSelectOne("SELECT * FROM settings WHERE NAME='HOOK_EVENT_" . DBSafe(strtoupper($event_name)) . "'");
if (!$rec['ID']) {
$rec = array();
$rec['NAME'] = 'HOOK_EVENT_' . strtoupper($event_name);
$rec['TITLE'] = $rec['NAME'];
$rec['TYPE'] = 'json';
$rec['PRIORITY'] = 0;
$rec['ID'] = SQLInsert('settings', $rec);
}
$data = json_decode($rec['VALUE'], true);
if (!isset($data[$module_name])) {
$data[$module_name] = 1;
$rec['VALUE'] = json_encode($data);
SQLUpdate('settings', $rec);
}
}
示例3: checkFromCache
/**
* Summary of checkFromCache
* @param mixed $key Key
* @return mixed
*/
function checkFromCache($key)
{
global $memory_cache;
if (isset($_SERVER['REQUEST_METHOD']) && !is_array($memory_cache)) {
$tmp = SQLSelect("SELECT KEYWORD, DATAVALUE FROM cached_values");
$total = count($tmp);
for ($i = 0; $i < $total; $i++) {
if ($tmp[$i]['DATAVALUE'] != '(too big)') {
$memory_cache[$tmp[$i]['KEYWORD']] = $tmp[$i]['DATAVALUE'];
}
}
}
if (isset($memory_cache[$key])) {
return $memory_cache[$key];
}
$rec = SQLSelectOne("SELECT * FROM cached_values WHERE KEYWORD = '" . DBSafe($key) . "'");
if ($rec['KEYWORD'] && $rec['DATAVALUE'] != '(too big)') {
return $rec['DATAVALUE'];
} else {
return false;
}
}
示例4: getGlobal
/**
* Title
*
* Description
*
* @access public
*/
function getGlobal($varname)
{
$value = SQLSelectOne("SELECT VALUE FROM pvalues WHERE PROPERTY_NAME = '" . DBSafe($varname) . "'");
if (isset($value['VALUE'])) {
return $value['VALUE'];
}
$tmp = explode('.', $varname);
if ($tmp[2]) {
$object_name = $tmp[0] . '.' . $tmp[1];
$varname = $tmp[2];
} elseif ($tmp[1]) {
$object_name = $tmp[0];
$varname = $tmp[1];
} else {
$object_name = 'ThisComputer';
}
$obj = getObject($object_name);
if ($obj) {
return $obj->getProperty($varname);
} else {
return 0;
}
}
示例5: LoadFile
}
$table_name = 'app_quotes';
if ($this->mode == 'update') {
global $file;
if (file_exists($file)) {
$tmp = LoadFile($file);
$ok = 1;
//$tmp=str_replace("\r", '', $tmp);
$lines = mb_split("\n", $tmp);
$total_lines = count($lines);
for ($i = 0; $i < $total_lines; $i++) {
//$values=explode("\t", $lines[$i]);
$rec = array();
$rec_ok = 1;
$rec['BODY'] = $lines[$i];
if ($rec['BODY'] == '') {
$rec_ok = 0;
}
if ($rec_ok) {
$old = SQLSelectOne("SELECT ID FROM " . $table_name . " WHERE BODY LIKE '" . DBSafe($rec['BODY']) . "'");
if ($old['ID']) {
$rec['ID'] = $old['ID'];
SQLUpdate($table_name, $rec);
} else {
SQLInsert($table_name, $rec);
}
$out["TOTAL"]++;
}
}
}
}
示例6: mysql
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once "./load_settings.php";
include_once DIR_MODULES . "control_modules/control_modules.class.php";
// ...
set_time_limit(0);
include_once DIR_MODULES . 'snmpdevices/snmpdevices.class.php';
$snmpdevices = new snmpdevices();
$socket = stream_socket_server("udp://0.0.0.0:162", $errno, $errstr, STREAM_SERVER_BIND);
// If we could not bind successfully, let's throw an error
if (!$socket) {
die($errstr);
} else {
do {
$pkt = stream_socket_recvfrom($socket, 512, 0, $peer);
if (preg_match('/:\\d+$/', $peer, $m)) {
$peer = str_replace($m[0], '', $peer);
}
echo date('Y-m-d H:i:s') . ' new snmp trap from ' . $peer . "\n";
$device = SQLSelectOne("SELECT ID FROM snmpdevices WHERE HOST LIKE '" . DBSafe($peer) . "'");
if ($device['ID']) {
$snmpdevices->readDevice($device['ID']);
} else {
$device['TITLE'] = $peer;
$device['HOST'] = $peer;
$device['ID'] = SQLInsert('snmpdevices', $device);
}
} while ($pkt !== false);
}
$db->Disconnect();
// closing database connection
示例7: DBSafe
exit;
}
if (isset($_REQUEST['latitude'])) {
//DebMes("GPS DATA RECEIVED: \n".serialize($_REQUEST));
if ($_REQUEST['deviceid']) {
$sqlQuery = "SELECT *\n FROM gpsdevices\n WHERE DEVICEID = '" . DBSafe($_REQUEST['deviceid']) . "'";
$device = SQLSelectOne($sqlQuery);
if (!$device['ID']) {
$device = array();
$device['DEVICEID'] = $_REQUEST['deviceid'];
$device['TITLE'] = 'New GPS Device';
if ($_REQUEST['token']) {
$device['TOKEN'] = $_REQUEST['token'];
}
$device['ID'] = SQLInsert('gpsdevices', $device);
$sqlQuery = "UPDATE gpslog\n SET DEVICE_ID = '" . $device['ID'] . "'\n WHERE DEVICEID = '" . DBSafe($_REQUEST['deviceid']) . "'";
SQLExec($sqlQuery);
}
$device['LAT'] = $_REQUEST['latitude'];
$device['LON'] = $_REQUEST['longitude'];
$device['UPDATED'] = date('Y-m-d H:i:s');
SQLUpdate('gpsdevices', $device);
}
$rec = array();
//$rec['ADDED'] = ($time) ? $time : date('Y-m-d H:i:s');
$rec['ADDED'] = date('Y-m-d H:i:s');
$rec['LAT'] = $_REQUEST['latitude'];
$rec['LON'] = $_REQUEST['longitude'];
$rec['ALT'] = round($_REQUEST['altitude'], 2);
$rec['PROVIDER'] = $_REQUEST['provider'];
$rec['SPEED'] = round($_REQUEST['speed'], 2);
示例8: run
function run()
{
// running current module
global $mode;
global $name;
$rep_ext = "";
if (preg_match('/\\.dev/is', $_SERVER['HTTP_HOST'])) {
$rep_ext = '.dev';
}
if (preg_match('/\\.jbk/is', $_SERVER['HTTP_HOST'])) {
$rep_ext = '.jbk';
}
if (preg_match('/\\.bk/is', $_SERVER['HTTP_HOST'])) {
$rep_ext = '.bk';
}
if ($rep_ext) {
$out['LOCAL_PROJECT'] = 1;
$out['REP_EXT'] = $rep_ext;
$out['HOST'] = $_SERVER['HTTP_HOST'];
$out['DOCUMENT_ROOT'] = dirname($_SERVER['SCRIPT_FILENAME']);
}
if ($mode == "edit") {
global $mode2;
$rec = SQLSelectOne("SELECT * FROM project_modules WHERE NAME='" . $name . "'");
$rec['NAME'] = $name;
if ($mode2 == "update") {
global $title;
global $category;
$rec['TITLE'] = $title;
$rec['CATEGORY'] = $category;
SQLUpdate("project_modules", $rec);
$this->redirect("?name={$name}&mode=edit");
} elseif ($mode2 == "show") {
if ($rec['HIDDEN']) {
$rec['HIDDEN'] = 0;
} else {
$rec['HIDDEN'] = 1;
}
SQLUpdate('project_modules', $rec);
$this->redirect("?");
} elseif ($mode2 == "install") {
$rec = SQLSelectOne("SELECT * FROM project_modules WHERE NAME='" . $name . "'");
SQLExec("DELETE FROM project_modules WHERE NAME='" . $name . "'");
@unlink(DIR_MODULES . $name . "/installed");
include_once DIR_MODULES . $name . "/" . $name . ".class.php";
$obj = "\$object{$i}";
$code .= "{$obj}=new " . $name . ";\n";
@eval($code);
// add module to control access
global $session;
$user = SQLSelectOne("SELECT * FROM admin_users WHERE LOGIN='" . DBSafe($session->data["USER_NAME"]) . "'");
if ($user['ID'] && !Is_Integer(strpos($user["ACCESS"], $name))) {
if ($user["ACCESS"] != '') {
$user["ACCESS"] .= ",{$name}";
} else {
$user["ACCESS"] = $name;
}
SQLUpdate('admin_users', $user);
}
SQLExec("UPDATE project_modules SET HIDDEN='" . (int) $rec['HIDDEN'] . "' WHERE NAME='" . $name . "'");
// redirect to edit
$this->redirect("?name={$name}&mode=edit");
} elseif ($mode2 == 'uninstall') {
SQLExec("DELETE FROM project_modules WHERE NAME='" . $name . "'");
@unlink(DIR_MODULES . $name . "/installed");
if (file_exists(DIR_MODULES . $name . "/" . $name . ".class.php")) {
include_once DIR_MODULES . $name . "/" . $name . ".class.php";
$obj = "\$object{$i}";
$code .= "{$obj}=new " . $name . ";\n";
$code .= "{$obj}" . "->uninstall();";
eval($code);
}
if ($out['LOCAL_PROJECT']) {
$this->redirect("?mode=repository_uninstall&module={$name}");
} else {
$this->redirect("?");
}
}
outHash($rec, $out);
}
if ($mode == 'repository_uninstall') {
global $module;
$out['MODULE'] = $module;
}
$out["MODE"] = $mode;
$this->getModulesList();
$lst = $this->modules;
for ($i = 0; $i < count($lst); $i++) {
$rec = SQLSelectOne("SELECT *, DATE_FORMAT(ADDED, '%M %d, %Y (%H:%i)') as DAT FROM project_modules WHERE NAME='" . $lst[$i]['FILENAME'] . "'");
if (isset($rec['ID'])) {
outHash($rec, $lst[$i]);
}
}
$out["MODULES"] = $lst;
$this->data = $out;
$p = new parser(DIR_TEMPLATES . $this->name . "/" . $this->name . ".html", $this->data, $this);
$this->result = $p->result;
}
示例9: SQLExec
for ($i = 0; $i < $total; $i++) {
SQLExec("DELETE FROM phistory WHERE VALUE_ID='" . $pvalues[$i]['ID'] . "'");
}
}
} else {
$new_rec = 1;
$rec['ID'] = SQLInsert($table_name, $rec);
// adding new record
}
$out['OK'] = 1;
if ($rec['CLASS_ID']) {
$objects = getObjectsByClass($rec['CLASS_ID']);
$total = count($objects);
$replaces = array();
for ($i = 0; $i < $total; $i++) {
$property = SQLSelectOne("SELECT ID FROM properties WHERE TITLE LIKE '" . DBSafe($rec['TITLE']) . "' AND OBJECT_ID=" . (int) $objects[$i]['ID'] . " AND CLASS_ID!=" . (int) $rec['CLASS_ID']);
if ($property['ID']) {
$replaces[] = $property['ID'];
}
}
$total = count($replaces);
for ($i = 0; $i < $total; $i++) {
SQLExec("UPDATE pvalues SET PROPERTY_ID=" . (int) $rec['ID'] . " WHERE PROPERTY_ID=" . (int) $replaces[$i]);
SQLExec("DELETE FROM properties WHERE ID=" . (int) $replaces[$i]);
}
}
} else {
$out['ERR'] = 1;
}
}
if (is_array($rec)) {
示例10: updateDevice
function updateDevice($id)
{
if (!defined('ONEWIRE_SERVER')) {
return 0;
}
$rec = SQLSelectOne("SELECT * FROM owdevices WHERE ID='" . $id . "'");
if (!$rec['ID']) {
return 0;
}
$ow = new OWNet(ONEWIRE_SERVER);
$device = '/' . $rec['UDID'];
$rec['CHECK_LATEST'] = date('Y-m-d H:i:s');
$rec['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + (int) $rec['ONLINE_INTERVAL']);
$old_status = $rec['STATUS'];
$tmp = $ow->get($device, OWNET_MSG_DIR, false);
if (!$tmp) {
$rec['STATUS'] = 0;
} else {
$rec['STATUS'] = 1;
}
SQLUpdate('owdevices', $rec);
if ($rec['STATUS'] != $old_status && ($rec['SCRIPT_ID'] || $rec['CODE'])) {
$params = array();
$params['DEVICE'] = $device;
$params['STATUS'] = $rec['STATUS'];
$params['STATUS_CHANGED'] = 1;
if ($rec['SCRIPT_ID']) {
runScript($rec['SCRIPT_ID'], $params);
} elseif ($rec['CODE']) {
try {
$code = $rec['CODE'];
$success = eval($code);
if ($success === false) {
DebMes("Error in 1-wire action code: " . $code);
}
} catch (Exception $e) {
DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
}
}
}
if (!$rec['STATUS']) {
return 0;
}
$changed_values = array();
$changed = 0;
$properties = explode(',', $tmp);
$totalp = count($properties);
for ($ip = 0; $ip < $totalp; $ip++) {
$sysname = str_replace($device . '/', '', $properties[$ip]);
//echo $properties[$ip]." (".$sysname."): ";
$prec = SQLSelectOne("SELECT * FROM owproperties WHERE DEVICE_ID='" . $rec['ID'] . "' AND SYSNAME='" . DBSafe($sysname) . "'");
if (!$prec['ID']) {
$prec['DEVICE_ID'] = $rec['ID'];
$prec['SYSNAME'] = $sysname;
$prec['PATH'] = $properties[$ip];
$prec['ID'] = SQLInsert('owproperties', $prec);
}
$old_value = $prec['VALUE'];
$value = $ow->get($properties[$ip], OWNET_MSG_READ, false);
if (is_null($value)) {
$ow->get("/", OWNET_MSG_DIR, false);
// hack. for some reason it didn't work correct without it on some devices
$value = $ow->get($properties[$ip], OWNET_MSG_READ, false);
}
if (!is_null($value)) {
$value = iconv("CP1251", "UTF-8", $value);
// value updated
$prec['VALUE'] = $value;
$prec['UPDATED'] = date('Y-m-d H:i:s');
$prec['CHECK_LATEST'] = $prec['UPDATED'];
SQLUpdate('owproperties', $prec);
//$rec['LOG']=date('Y-m-d H:i:s')." ".$prec['SYSNAME'].": ".$prec['VALUE']."\n".$rec['LOG'];
//SQLUpdate('owdevices', $rec);
if ($prec['LINKED_OBJECT'] && $prec['LINKED_PROPERTY']) {
setGlobal($prec['LINKED_OBJECT'] . '.' . $prec['LINKED_PROPERTY'], $prec['VALUE'], array($this->name => '0'));
}
if ($old_value != $value) {
$changed = 1;
$changed_values[$prec['SYSNAME']] = array('OLD_VALUE' => $old_value, 'VALUE' => $prec['VALUE']);
}
}
}
if ($changed) {
$params = $changed_values;
$params['DEVICE'] = $device;
if ($rec['SCRIPT_ID']) {
runScript($rec['SCRIPT_ID'], $params);
} elseif ($rec['CODE']) {
try {
$code = $rec['CODE'];
$success = eval($code);
if ($success === false) {
DebMes("Error in code: " . $code);
}
} catch (Exception $e) {
DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
}
}
}
}
示例11: DBSafe
<?php
global $session;
global $uid;
if ($nid != '') {
$qry .= " AND USER_ID LIKE '%" . DBSafe($nid) . "%'";
$out['USER_ID'] = $nid;
}
global $name;
if ($name != '') {
$qry .= " AND NAME LIKE '%" . DBSafe($name) . "%'";
$out['NAME'] = $name;
}
// FIELDS ORDER
global $sortby_user;
if (!$sortby_user) {
$sortby_user = $session->data['tlg_user_sort'];
} else {
if ($session->data['tlg_user_sort'] == $sortby_user) {
if (Is_Integer(strpos($sortby_user, ' DESC'))) {
$sortby_user = str_replace(' DESC', '', $sortby_user);
} else {
$sortby_user = $sortby_user . " DESC";
}
}
$session->data['tlg_user_sort'] = $sortby_user;
}
if (!$sortby_user) {
$sortby_user = "USER_ID";
}
$out['SORTBY'] = $sortby_user;
示例12: SQLInsert
$rec['TITLE'] = 'ws';
$rec['ID'] = SQLInsert('objects', $rec);
$obj = getObject('ws');
}
$object_rec = SQLSelectOne("SELECT * FROM objects WHERE ID = '" . $obj->id . "'");
if (!$object_rec['CLASS_ID']) {
$class_rec = array();
$class_rec['TITLE'] = 'WeatherStations';
$class_rec['SUB_LIST'] = 0;
$class_rec['PARENT_LIST'] = 0;
$class_rec['ID'] = SQLInsert('classes', $class_rec);
$object_rec['CLASS_ID'] = $class_rec['ID'];
SQLUpdate('objects', $object_rec);
}
foreach ($known_fields as $k => $v) {
$prop_rec = SQLSelectOne("SELECT * FROM properties WHERE TITLE LIKE '" . DBSafe($k) . "' AND CLASS_ID = '" . $object_rec['CLASS_ID'] . "'");
if (!$prop_rec['ID']) {
$prop_rec['CLASS_ID'] = $object_rec['CLASS_ID'];
$prop_rec['TITLE'] = $k;
$prop_rec['KEEP_HISTORY'] = 7;
$prop_rec['ID'] = SQLInsert('properties', $prop_rec);
}
}
$res = '';
$updated = array();
foreach ($known_fields as $k => $v) {
if ($v < 0) {
continue;
}
$res .= $k . ' = ' . $data[(int) $v] . "\n";
$old_value = getGlobal('ws.' . $k);
示例13: htmlspecialchars
}
if (!$my_meth['ID']) {
$out['CALL_PARENT'] = 1;
} else {
$out['CODE'] = htmlspecialchars($my_meth['CODE']);
$out['SCRIPT_ID'] = $my_meth['SCRIPT_ID'];
$out['CALL_PARENT'] = (int) $my_meth['CALL_PARENT'];
}
$out['OVERWRITE'] = 1;
}
include_once DIR_MODULES . 'classes/classes.class.php';
$cl = new classes();
$methods = $cl->getParentMethods($rec['CLASS_ID'], '', 1);
$total = count($methods);
for ($i = 0; $i < $total; $i++) {
$my_meth = SQLSelectOne("SELECT ID FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($methods[$i]['TITLE']) . "'");
if ($my_meth['ID']) {
$methods[$i]['CUSTOMIZED'] = 1;
}
}
$out['METHODS'] = $methods;
}
// step: history
if ($this->tab == 'history') {
}
if (is_array($rec)) {
foreach ($rec as $k => $v) {
if (!is_array($v)) {
$rec[$k] = htmlspecialchars($v);
}
}
示例14: registerError
/**
* Title
*
* Description
*
* @access public
*/
function registerError($code = 'custom', $details = '')
{
$code = trim($code);
if (!$code) {
$code = 'custom';
}
$error_rec = SQLSelectOne("SELECT * FROM system_errors WHERE CODE LIKE '" . DBSafe($code) . "'");
if (!$error_rec['ID']) {
$error_rec['CODE'] = $code;
$error_rec['KEEP_HISTORY'] = 1;
$error_rec['ID'] = SQLInsert('system_errors', $error_rec);
}
$error_rec['LATEST_UPDATE'] = date('Y-m-d H:i:s');
$error_rec['ACTIVE'] = (int) $error_rec['ACTIVE'] + 1;
SQLUpdate('system_errors', $error_rec);
$history_rec = array();
$history_rec['ERROR_ID'] = $error_rec['ID'];
$history_rec['COMMENTS'] = $details;
$history_rec['ADDED'] = $error_rec['LATEST_UPDATE'];
//Temporary disabled
/*
$history_rec['PROPERTIES_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=', 0);
$history_rec['METHODS_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=methods', 0);
$history_rec['SCRIPTS_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=scripts', 0);
$history_rec['TIMERS_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=timers', 0);
$history_rec['EVENTS_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=events', 0);
$history_rec['DEBUG_DATA']=getURL(BASE_URL.ROOTHTML.'popup/xray.html?ajax=1&md=xray&op=getcontent&view_mode=debmes', 0);
*/
$history_rec['ID'] = SQLInsert('system_errors_data', $history_rec);
if (!$error_rec['KEEP_HISTORY']) {
SQLExec("DELETE FROM system_errors_data WHERE ID!='" . $history_rec['ID'] . "'");
}
}
示例15: install
function install()
{
//$className = 'Push';
//$objectName = 'PushBullet';
//$propertis = array('API_KEY1', 'Device1');
$rec = SQLSelectOne("SELECT ID FROM classes WHERE TITLE LIKE '" . DBSafe($className) . "'");
if (!$rec['ID']) {
$rec = array();
$rec['TITLE'] = $className;
//$rec['PARENT_LIST']='0';
$rec['DESCRIPTION'] = 'Push-notes';
$rec['ID'] = SQLInsert('classes', $rec);
}
$obj_rec = SQLSelectOne("SELECT ID FROM objects WHERE CLASS_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($objectName) . "'");
if (!$obj_rec['ID']) {
$obj_rec = array();
$obj_rec['CLASS_ID'] = $rec['ID'];
$obj_rec['TITLE'] = $objectName;
$obj_rec['DESCRIPTION'] = 'Настройки';
$obj_rec['ID'] = SQLInsert('objects', $obj_rec);
}
for ($i = 0; $i < count($propertis); $i++) {
$prop_rec = SQLSelectOne("SELECT ID FROM properties WHERE OBJECT_ID='" . $obj_rec['ID'] . "' AND TITLE LIKE '" . DBSafe($propertis[$i]) . "'");
if (!$prop_rec['ID']) {
$prop_rec = array();
$prop_rec['TITLE'] = $propertis[$i];
$prop_rec['OBJECT_ID'] = $obj_rec['ID'];
$prop_rec['ID'] = SQLInsert('properties', $prop_rec);
}
}
parent::install();
}