/** * loads the configuration and sets it * * @return void * @author Craig Ulliott */ public static function loadConfiguration() { // load AWS config file $config = getConfiguration('aws'); // cache to this object self::$access_key = $config['access_key']; self::$secret_key = $config['secret_key']; self::$pem_certificate = $config['pem_certificate']; self::$pem_pk = $config['pem_pk']; return true; }
public static function get_instance($sKey, $sSecret) { if ($sKey && !self::$aInstances[$sKey]) { self::$aInstances[$sKey] = new SimpleDB($sKey, $sSecret); if (!self::$aInstance) { self::$aInstance = self::$aInstances[$sKey]; } } if ($sKey) { return self::$aInstances[$sKey]; } else { return self::$aInstance; } }
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Auto-XHPorf List</title> <style> body {margin: 10px;} td {font-size:12px;word-break: break-all;} </style> </head> <body> <?php error_reporting(E_ALL); ini_set('display_errors', 1); date_default_timezone_set('Asia/Shanghai'); $db = new SimpleDB(); $err = array(1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', 8 => 'E_NOTICE', 16 => 'E_CORE_ERROR', 32 => 'E_CORE_WARNING', 64 => 'E_COMPILE_ERROR', 128 => 'E_COMPILE_WARNING', 256 => 'E_USER_ERROR', 512 => 'E_USER_WARNING', 1024 => 'E_USER_NOTICE', 2048 => 'E_STRICT', 4096 => 'E_RECOVERABLE_ERROR', 8192 => 'E_DEPRECATED', 16384 => 'E_USER_DEPRECATED', 32767 => 'E_ALL'); ?> <h4>Auto-XHProf List</h4> <table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#AAA"> <tr bgcolor="#CCC"> <td width="5%">ID</td><td width="25%">URL</td><td width="8%">Resp Time</td><td>Error Desc</td><td width="10%">Profile</td><td width="10%">Client Time</td></tr> <?php $rows = $db->query("SELECT * FROM ax_log ORDER BY id DESC LIMIT 100"); if ($rows) { foreach ($rows as $row) { $error_id = $row['error_id']; $xhprof_id = $row['xhprof_id']; if (!empty($error_id)) { $error = $db->query("SELECT * FROM ax_error WHERE id='" . $error_id . "'"); if ($error != null) {
/** +---------------------------------------------------------- * 取得数据库类实例 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @return mixed 返回数据库驱动类 +---------------------------------------------------------- */ public static function getInstance($db_config = '') { if (self::$_instance == null) { self::$_instance = new Db($db_config); } return self::$_instance; }
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : 0; $uname = t($_GET['uname']) ? t($_GET['uname']) : 'guest'; $agent = getBrower(); $ip = getClientIp(); $refer = addslashes($_SERVER['HTTP_REFERER']); $isGuest = $uid == -1 || $uid == 0 ? 1 : 0; $isIntranet = substr($ip, 0, 2) == '10.' ? 1 : 0; $cTime = time(); $ext = ''; //加载数据库查询类 require SITE_PATH . '/addons/library/SimpleDB.class.php'; //全局配置 $config = (require SITE_PATH . '/config/config.inc.php'); //数据库配置 $dbconfig = !empty($config['ONLINE_DB']) ? array_merge($config, $config['ONLINE_DB']) : $config; $db = new SimpleDB($dbconfig); //记录在线统计. if ($_GET['action'] == 'trace') { /* ===================================== step 1 record track ========================================== */ $sql = "INSERT INTO " . $config['DB_PREFIX'] . "online_logs \n\t\t\t\t(day,uid,uname,action,refer,isGuest,isIntranet,ip,agent,ext)\n\t\t\t\tVALUES ( CURRENT_DATE,'{$uid}','{$uname}','{$action}','{$refer}','{$isGuest}','{$isIntranet}','{$ip}','{$agent}','{$ext}');"; $result = $db->execute("{$sql}"); /* ===================================== step 2 update hits ========================================== */ //memcached更新.写入全局点击量.每个应用的点击量.每个版块的点击量. /* ===================================== step 3 update heartbeat ========================================== */ if (cookie('online_update') + $check_time < $cTime) { //刷新用户在线时间 //设置10分钟过期 cookie('online_update', $cTime, 7200); //$_SESSION['online_pageviews'] = 0; //判断是否存在记录. if ($uid > 0) {
public function __construct($limits) { $this->limits = $limits; $this->log = new Logger('limit', 'time-limit'); $this->log->debug = true; $this->log->verbose = true; $this->system = new MACCommands(); $this->system->setLogger($this->log); $this->user = $this->system->currentUser(); $this->system->setUser($this->user); if ($this->getLimit($this->user) !== false) { $file = sprintf('sqlite:%s/time-limit.db', __DIR__); $sqlite = new SimpleDB($file); $sqlite->setLogger($this->log); $this->time = new TimeLimitDB($sqlite); $this->time->setLogger($this->log); $this->time->init(); } }
/** * list the domains and ensure this new one was deleted * * @depends testDeleteDomain */ function testDomainWasDeleted() { // sleep for atleast one second between methods, it is only 'eventual consistency' sleep(1); $result = SimpleDB::listDomains(); // look for the domain in the list $this->assertNotContains($this->test_domain, $result); }
public function deleteStyle($id) { $this->sdb->query("DELETE FROM hb_mod_styles WHERE id=?", array($id)); $this->addInfo("Selected style has been removed"); return true; }
//获取参数 $url = $_GET['url']; //初步验证合法性 $result = preg_match('/^[a-zA-Z0-9]+$/', $url, $match); if (!$result) { die('error01,wrong parameters!'); } $url_id = getDncodeNum($url); if ($url_id <= 0) { die('error02,wrong parameters!'); } //加载数据库查询类 require SITE_PATH . '/addons/libs/SimpleDB.class.php'; //引入数据库配置 $db_config = (require SITE_PATH . '/config.inc.php'); $db = new SimpleDB($db_config); //查询短网址记录 - 有条件的,此处可用memcached做一层缓存 $result = $db->query("SELECT * FROM " . $db_config['DB_PREFIX'] . "url where id='" . $url_id . "' limit 1"); //状态为1的 跳转到正确地址 if ($result[0]['status'] == 1) { header('location:' . $result[0]['url']); } else { die('error03,wrong parameters!'); } //本地化 URL解码方法 将字母转换成数字ID function getDncodeNum($num) { //编码符号集一定要与加密的相同 $index = "HwpGAejoUOPr6DbKBlvRILmsq4z7X3TCtky8NVd5iWE0ga2MchSZxfn1Y9JQuF"; $out = 0; $len = strlen($num) - 1;
<?php /** * Created by IntelliJ IDEA. * User: ssingan * Date: 8/5/15 * Time: 12:26 AM */ include "./SimpleDB.php"; $simpleDB = new SimpleDB(); $loopCondition = true; while ($loopCondition) { $line = readline(); $parts = preg_split('/\\s+/', $line); if (count($parts) == 0 || count($parts) > 3) { print "Invalid input\n"; break; } $command = strtoupper($parts[0]); switch ($command) { case "END": $loopCondition = false; break; case "SET": if (count($parts) != 3) { print "Invalid input\n"; $loopCondition = false; break; } $simpleDB->setValue($parts[1], $parts[2]); break;
preg_match_all("/\n/", $this->read($this->table_name), $matches); return count($matches[0]) / 2; } function removeslashes($string) { $string = implode("", explode("\\", $string)); return stripslashes(trim($string)); } } //====================================================================== //clear cache session_start(); $_SESSION = array(); session_destroy(); //create db object $sdb = new SimpleDB("chat_data"); //clear chat if needed if (isset($_GET['action']) and $_GET['action'] == "delete") { $sdb->clear_db(); } //return message count if asked for if (isset($_GET['action']) and $_GET['action'] == "get_msg_count") { echo $sdb->get_msg_count(); } //insert if (isset($_GET['msg_data'])) { if ($_GET['msg_data'] != "") { $sdb->insert(array(addslashes($_GET['msg_data']))); } else { $result = ""; foreach ($sdb->getRows(1) as $msg) {
public function delete($pos) { if ($this->fileWrite == false) { //if not saving changes to file if (file_put_contents($this->walPath, '0;' . $pos . PHP_EOL, FILE_APPEND) === false) { return false; } else { if (++$this->opNumber > $this->maxOps) { return $this->saveLoggedData($this->dbFileVer); } } } return parent::delete($pos); }
<?php $debug = !empty($_GET['debug']); define('DEBUG', $debug); if ($debug) { header("Content-type: text/plain"); } require_once 'utils.inc.php'; require_once 'SimpleDB.class.php'; $sdb = new SimpleDB(''); $r = $sdb->createDomain('UnitTest'); $list = $sdb->listDomains(); print_r($list); Utils::printResult('CreateDomain', in_array('UnitTest', $list), $r); $sdb->setDomain('UnitTest'); $a = array('name' => 'Bob', 'age' => 30); $r = $sdb->putAttributesAssoc('bob', $a); Utils::printResult('putAttributesAssoc', true, $r); $r = $sdb->getAttributes('bob'); Utils::printResult('getAttributes', $r['name'] == 'Bob', $r); $sdb->setSingleAttr('bob', 'foo', 'bar'); $r = $sdb->getAttributes('bob'); Utils::printResult('setSingleAttr', $r['foo'] == 'bar'); $a = array('alice' => array('name' => 'Alice', 'age' => 50), 'charlie' => array('name' => 'Charlie', 'age' => 20)); $r = $sdb->batchPutAttributesAssoc($a); Utils::printResult('batchPutAttributesAssoc', true, $r); $r = $sdb->query("SELECT * FROM UnitTest WHERE age>'25'"); Utils::printResult('query', count($r) == 2, $r); $r = $sdb->singleAttrQuery('name', 'Alice'); Utils::printResult('singleAttrQuery - single val', count($r), $r); $r = $sdb->singleAttrQuery('name', array('Alice', 'Bob'));
require_once CORE_PATH . 'client/wib/whereivebeen_wrapper.php'; // ------------------------------------------------------ // system configuration require_once CORE_PATH . 'config.php'; // ------------------------------------------------------ // make cookies work in IE iframes header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); // if we're in dev, enable all query logs if (ENV == 'dev' || array_val($_REQUEST, 'mongoose7')) { Log::enableAll(); } // all users get a php session. we have our own session handler which uses the database session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc')); session_start(); // are we overriding the test with a request variable if ($current_test = array_val($_REQUEST, 'AB_USER_TEST')) { // save this for the duration of the users session $_SESSION['AB_USER_TEST'] = $current_test; } else { // try and pull it from the session if (!($current_test = array_val($_SESSION, 'AB_USER_TEST'))) { // we dont have one in the session then assign a new one $current_test = ABTest::getRandomTest(); $_SESSION['AB_USER_TEST'] = $current_test; } } // pass this to the AB framework, the framework will show content for this test only ABTest::assignTest($current_test); // load the configuration for simpledb SimpleDB::loadConfiguration();