Esempio n. 1
0
 /**
  * Construtor
  */
 public function __construct()
 {
     // Abre conexao
     $this->db = DB::open();
     $this->fields = $this->getFields(false);
     $this->fields_buscar = $this->fields;
     $this->strip_tags = true;
 }
 function put_stats($ip, $browser, $refering)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     $sql = "INSERT INTO table_name(refer,ip,browser,recieved) VALUES('{$refering}','{$ip}','{$browser}',now())";
     $result = $db->query($sql);
 }
Esempio n. 3
0
 static function setUpBeforeClass()
 {
     DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
     $sql = sql_split("create table qwerty ( foo char(12), bar char(12) );\n\t\tcreate table foo(id int, name char(12));\n\t\tcreate table bar(id int, name char(12), foo int);\n\t\tcreate table gallery (\n\t\t\tid integer primary key,\n\t\t\ttitle char(48)\n\t\t);\n\t\tcreate table cover (\n\t\t\tid integer primary key,\n\t\t\tgallery integer unique,\n\t\t\ttitle char(48)\n\t\t);\n\t\tcreate table item (\n\t\t\tid integer primary key,\n\t\t\tgallery_id integer,\n\t\t\ttitle char(48)\n\t\t);\n\t\tinsert into gallery (id, title) values (1, 'Gallery One');\n\t\tinsert into cover (id, gallery, title) values (1, 1, 'Cover One');\n\t\tinsert into item (id, gallery_id, title) values (1, 1, 'Item One');\n\t\tinsert into item (id, gallery_id, title) values (2, 1, 'Item Two');\n\t\tinsert into item (id, gallery_id, title) values (3, 1, 'Item Three');\n\t\tinsert into gallery (id, title) values (2, 'Gallery Two');\n\t\tinsert into cover (id, gallery, title) values (2, 2, 'Cover Two');\n\t\tinsert into item (id, gallery_id, title) values (4, 2, 'Item Four');\n\t\tinsert into item (id, gallery_id, title) values (5, 2, 'Item Five');\n\t\tinsert into item (id, gallery_id, title) values (6, 2, 'Item Six');\n\t\tcreate table author (\n\t\t\tid integer primary key,\n\t\t\tname char(32)\n\t\t);\n\t\tcreate table book (\n\t\t\tid integer primary key,\n\t\t\tname char(32)\n\t\t);\n\t\tcreate table book_author (\n\t\t\tbook int not null,\n\t\t\tauthor int not null\n\t\t);\n\t\tinsert into author (id, name) values (1, 'Johnny Fast Fingers');\n\t\tinsert into author (id, name) values (2, 'Frankie Bazzar');\n\t\tinsert into book (id, name) values (1, 'Johnny & Frankie');\n\t\tinsert into book (id, name) values (2, 'Jamaican Me Crazy');\n\t\tinsert into book_author (book, author) values (1, 1);\n\t\tinsert into book_author (book, author) values (1, 2);\n\t\tinsert into book_author (book, author) values (2, 1);\n\t\tinsert into book_author (book, author) values (2, 2);\n\t\tcreate table next_test (\n\t\t\tfieldname int not null\n\t\t);\n\t\t");
     foreach ($sql as $query) {
         DB::execute($query);
     }
     self::$q = new Qwerty();
 }
Esempio n. 4
0
function get_links()
{
    include_once "db.inc.php";
    $db = new DB();
    $db->open();
    $query = "SELECT * FROM links ORDER BY order_";
    $result = $db->query($query);
    $num_results = $db->numRows($result);
    for ($i = 0; $i < $num_results; $i++) {
        $row = $db->fetchArray($result);
        $txttitle = str_replace("_", " ", $row[title]);
        echo '<li><a href="' . $row[url] . '">' . $txttitle . '</a></li>';
    }
}
Esempio n. 5
0
 function test_open()
 {
     // test a bad connection
     $this->assertFalse(DB::open($this->bad_conf));
     $this->assertEquals('could not find driver', DB::error());
     $this->assertEquals(0, DB::count());
     // test a master connection
     $this->assertTrue(DB::open($this->conf));
     $this->assertEquals(1, DB::count());
     // test a second connection
     $this->assertTrue(DB::open($this->conf2));
     $this->assertEquals(2, DB::count());
     unset(DB::$connections['slave_1']);
 }
Esempio n. 6
0
    static function setUpBeforeClass()
    {
        DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
        DB::execute('create table `lock` (
			id integer primary key,
			user int not null,
			resource varchar(72) not null,
			resource_id varchar(72) not null,
			expires datetime not null,
			created datetime not null,
			modified datetime not null
		)');
        User::$user = (object) array('id' => 1);
        self::$lock = new Lock('test', 'one');
    }
Esempio n. 7
0
    static function setUpBeforeClass()
    {
        DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
        DB::execute('create table user (
			id integer primary key,
			email char(72) unique not null,
			password char(128) not null,
			session_id char(32) unique,
			expires datetime not null,
			name char(72) not null,
			type char(32) not null,
			signed_up datetime not null,
			updated datetime not null,
			userdata text not null
		)');
    }
Esempio n. 8
0
    static function setUpBeforeClass()
    {
        DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
        DB::execute('create table foobar (id int not null, name char(32) not null)');
        if (!DB::execute('create table versions (
			id integer primary key,
			class char(72) not null,
			pkey char(72) not null,
			user int not null,
			ts datetime not null,
			serialized text not null
		)')) {
            die('Failed to create versions table');
        }
        if (!DB::execute('create index versions_class on versions (class, pkey, ts)')) {
            die('Failed to create versions_class index');
        }
        if (!DB::execute('create index versions_user on versions (user, ts)')) {
            die('Failed to create versions_user index');
        }
        User::$user = false;
    }
Esempio n. 9
0
    static function setUpBeforeClass()
    {
        DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
        DB::$prefix = 'elefant_';
        $sql = sql_split('
			create table #prefix#webpage (
				id char(72) not null primary key,
				title char(72) not null,
				menu_title char(72) not null,
				window_title char(72) not null,
				access char(12) not null,
				layout char(48) not null,
				description text,
				keywords text,
				body text
			);
			insert into #prefix#webpage (id, title, menu_title, window_title, access, layout, description, keywords, body) values ("index", "Welcome to Elefant", "Home", "", "public", "default", "", "", \'<table><tbody><tr><td><h3>Congratulations!</h3>You have successfully installed Elefant, the refreshingly simple new PHP web framework and CMS.</td><td><h3>Getting Started</h3>To log in as an administrator and edit pages, write a blog post, or upload files, go to <a href="/admin">/admin</a>.</td><td><h3>Developers</h3>Documentation, source code and issue tracking can be found at <a href="http://github.com/jbroadway/elefant">github.com/jbroadway/elefant</a></td></tr></tbody></table>\');
		');
        foreach ($sql as $query) {
            if (!DB::execute($query)) {
                die(DB::error());
            }
        }
    }
 function insert_room_gag($ip, $room)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     $query = "INSERT INTO roomgag (gaggedfrom, gaggedip) VALUES ('{$room}', '{$ip}');";
     $result = $db->query($query);
     $DEBUG = 0;
 }
Esempio n. 11
0
 function showZoomedTweets($skipevery = 0, $count = 50)
 {
     //verify logged in status
     $db = new DB();
     $db->open();
     if (false) {
         echo "Need to log in first<br>";
     } else {
         $res = $this->friendsTimeline(false, false, $count);
         //verify ok results
         if ($res === false) {
             echo "ERROR<hr/>";
             echo "<pre>";
             print_r($this->responseInfo);
             print_r($this->responseInfo);
             echo "</pre>";
         } else {
             echo '<h2>User Timeline: </h2>';
             //print whole response:
             //echo $res->asXML() . '<br>';
             $loopcount = 0;
             $skipcount = 0;
             foreach ($res->status as $status) {
                 if ($skipcount + 1 != $skipevery || $skipevery == 0) {
                     $tweet = new Tweet($status);
                     $tweet->display();
                     $db->insertUpdateTweet($tweet);
                     print '<hr>';
                     $skipcount++;
                     $loopcount++;
                 } else {
                     //print 'Excluded!';
                     $skipcount = 0;
                 }
             }
         }
     }
     $db->close();
 }
Esempio n. 12
0
<?php

$vipid = $_GET['vipid'];
$openid = $_GET['openid'];
$nickname = $_GET['nickname'];
$pid = $_GET['pid'];
$tel = $_GET['tel'];
$totalamount = $_GET['totalamount'];
$totalinterest = $_GET['totalinterest'];
require_once "conf/db_mysqlwx.class.php";
$conn = new DB();
$conn->open();
$query = mysql_query("INSERT INTO `vip_wechat`(`vipid`, `openid`, `nickname`, `pid`,`tel`,`totalamount`,`totalinterest`) VALUES ('{$vipid}','{$openid}','{$nickname}', '{$pid}','{$tel}','{$totalamount}','{$totalinterest}')");
if ($query) {
    echo "<script>location.href='tz.php';</script>";
} else {
    echo "<script>alert( '您的积分卡已经被某个微信号绑定,如有疑问请联系门店前台! ')</script>";
    echo "<script>location.href='hykbindsuccess.php';</script>";
}
mysql_free_result($query);
$conn->close();
Esempio n. 13
0
 */
function __autoload($file)
{
    $paths = array('app/', 'app/ado/', 'app/control/', 'app/model/', 'app/inc/', 'app/config/');
    foreach ($paths as $path) {
        if (is_file($path . $file . '.class.php')) {
            require $path . $file . '.class.php';
            break;
        }
    }
}
// Security
require 'session_login.php';
// Functions
function pr($array)
{
    echo '<div style="border:2px solid #000;padding:10px;background:#e1e1e1;margin:10px;">';
    echo '<pre>';
    print_r($array);
    echo '</pre>';
    echo '</div>';
}
// Get custom
$get = array();
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) {
    $qs = $_SERVER['QUERY_STRING'];
    parse_str($qs, $get);
}
// Open con
DB::open();
 function characters($user)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     echo '<CENTER> CHARACTERS PLAYED:<BR><table width="100%" border="o" cellspacing="1" cellpadding="1">';
     $query = "SELECT * FROM Bios where username='******' ORDER BY bioid";
     $result = $db->query($query);
     $num_results = $db->numRows($result);
     for ($i = 0; $i < $num_results; $i++) {
         $row = $db->fetchArray($result);
         echo '<tr> <td><li><a href=' . $stcfg[RootDir] . '/?userbio=' . $row['bioname'] . '>';
         echo $row['bioname'];
         echo '</a></li></td></tr>';
     }
     echo '</table>';
 }
Esempio n. 15
0
 public function getAccessToken()
 {
     //实例化数据库类并连接数据库
     $db = new DB();
     $db->open();
     $accessToken = $db->get_field('wx_config', "_key='WX_ACCESS_TOKEN'", '_value');
     $access = $accessToken ? json_decode($access, true) : array();
     if ($access['expires_in'] < time()) {
         //已经过期
         $app = self::getApp();
         //获取appid和appsecret
         include_once HANDLE_DIR . 'tools.class.php';
         $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $app['appid'] . '&secret=' . $app['appsec'];
         $access = curl_get($url);
         $access_arr = json_decode($access, true);
         $access_arr['expires_in'] += time();
         $data = array('_key' => 'WX_ACCESS_TOKEN', '_value' => json_encode($access_arr));
         //保存
         if (empty($accessToken)) {
             //需要创建
             $db->insert('wx_config', $data);
         } else {
             //需要更新
             $db->update('wx_config', $data, "_key='WX_ACCESS_TOKEN'");
         }
         return $access_arr['access_token'];
     } else {
         return $access['access_token'];
     }
 }
 function insertbanneduser($banuser, $room, $ip, $type)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     $query = "INSERT INTO discipline (username, room, ip, type) VALUES ('{$banuser}', '{$room}', '{$ip}', '{$type}');";
     $result = $db->query($query);
     echo $query;
 }
Esempio n. 17
0
 /**
  * 更新表中的属性值
  */
 public function updateParamById($tableName, $atrName, $atrValue, $key, $value)
 {
     $db = new DB();
     $db->open();
     if (mysql_query("UPDATE " . $tableName . " SET {$key} = '{$value}' WHERE {$atrName} = '{$atrValue}' ")) {
         //$key不要单引号
         $db->close();
         return true;
     } else {
         $db->close();
         return false;
     }
 }
Esempio n. 18
0
// update config file
$config_plain = file_get_contents('conf/config.php');
$config_plain = preg_replace('/site_key = .*/', 'site_key = "' . md5(uniqid(rand(), true)) . '"', $config_plain, 1);
if (!file_put_contents('conf/config.php', $config_plain)) {
    // currently it is not error, just warning
    Cli::out('** Warning: Failed to write to conf/config.php.');
}
$conf = parse_ini_file('conf/config.php', true);
// connect to the database
$connected = false;
DB::$prefix = isset($conf['Database']['prefix']) ? $conf['Database']['prefix'] : '';
unset($conf['Database']['prefix']);
foreach (array_keys($conf['Database']) as $key) {
    if ($key == 'master') {
        $conf['Database'][$key]['master'] = true;
        if (!DB::open($conf['Database'][$key])) {
            Cli::out('** Error: Could not connect to the database. Please check the', 'error');
            Cli::out('          settings in conf/config.php and try again.', 'error');
            echo "\n";
            Cli::out('          ' . DB::error(), 'error');
            return;
        }
        $connected = true;
        break;
    }
}
if (!$connected) {
    Cli::out('** Error: Could not find a master database. Please check the', 'error');
    Cli::out('          settings in conf/config.php and try again.', 'error');
    return;
}
 function getsilenced($roomname, $ip, $sitesilence)
 {
     include_once "db.inc.php";
     $db = new DB();
     $db->open();
     $query = "SELECT * from sitesilence";
     $result = $db->query($query);
     $num_results = $db->numRows($result);
     if ($DEBUG) {
         echo $query . "<br>\n";
     }
     if ($DEBUG) {
         echo 'Invalid query: ' . mysql_error() . "<br>\n";
     }
     for ($i = 0; $i < $num_results; $i++) {
         $row = $db->fetchArray($result);
         if (strstr($ip, $row[silencedip])) {
             $sitesilence = '1';
         }
     }
     return $sitesilence;
 }
Esempio n. 20
0
<?php

include '../lib/db.class.php';
//instancia classe do db
$db = new DB();
if (!$db->open()) {
    echo $db->erroMsg . '\\n';
}
$sql = "SELECT COUNT(*), candidato.nome, candidato.sobrenome, partido.sigla, parametro.status\n     FROM (((eleicao.votacao INNER JOIN  eleicao.candidato ON votacao.idcandidato_candidato = candidato.idcandidato)\n     INNER JOIN eleicao.partido ON candidato.idpartido_partido =  partido.idpartido)\n     INNER JOIN eleicao.parametro ON votacao.idparametro_parametro = parametro.idparametro)\n     WHERE parametro.idtipo_tipo = 1\n     GROUP BY candidato.nome;";
//$sql = "INSERT INTO eleicao.eleitor VALUES ('','06123422120','Celio','Rosa Orcino','*****@*****.**',977)";
if (!$db->query($sql)) {
    echo $db->erroMsg . '\\n';
}
//echo "Numero linhas: ".$db->num_rows()." \n";
//$data = $db->fetch();
//$return = '';
//print_r($data);
//echo $data['0'];
//echo $data['1'];
//echo $data['2'];
while ($data = $db->fetch()) {
    print_r($data);
    //$return .= "<option value='".$data['idestado']."'>".utf8_encode($data['nome'])."</option>";
    //echo "Nome.: ".stripslashes($data['nome'])." \n";
    //echo "Email: ".stripslashes($data['email'])." \n";
    //echo "===============================\n\n";
    //$i++;
}
//echo 'Total Rows: '.$db->num_rows()."\n";
$db->close();
//print_r($return);
Esempio n. 21
0
	public static function run()
	{
		$config = new Config('config/config.php');
		CoOrg::init($config, 'app', 'plugins');
		DB::open($config->get('dbdsn'), $config->get('dbuser'),
		         $config->get('dbpass'));
		
		if (get_magic_quotes_gpc())
		{
			self::clearMessAfterMagicQuotes();
		}
		
		$params = array();
		$post = false;
		if (array_key_exists('r', $_GET)) {
			$request = $_GET['r'];
			if (count($_GET) > 1) {
				$params = $_GET;
			} else if (count($_POST) > 0) {
				$params = $_POST;
				$post = true;
			}
		} else {
			$request = '';
		}
		self::process($request, $params, $post);
	}
Esempio n. 22
0
<?php

require_once 'PHPUnit/Framework.php';
define('COORG_UNIT_TEST', true);
require_once 'coorg/testing/domainexists.test.php';
require_once 'coorg/coorg.class.php';
require_once 'coorg/testing/model.test.class.php';
require_once 'coorg/testing/coorg.test.class.php';
require_once 'coorg/testing/coorgsmarty.test.class.php';
require_once 'coorg/testing/header.test.class.php';
require_once 'coorg/testing/mail.test.class.php';
require_once 'coorg/testing/state.test.class.php';
require_once 'coorg/testing/files.test.class.php';

DB::open('sqlite::memory:');

function prepare()
{
	$q = DB::prepare('DROP TABLE IF EXISTS FooBars');
	$q->execute();

	$q = DB::prepare('DROP TABLE IF EXISTS Foo');
	$q->execute();
	
	$q = DB::prepare('DROP TABLE IF EXISTS Bar');
	$q->execute();

	$q = DB::prepare('DROP TABLE IF EXISTS IsAMockModel');
	$q->execute();

	$q = DB::prepare('DROP TABLE IF EXISTS MockModel');
Esempio n. 23
0
 /**
  * 更新表中的属性值
  */
 public function updateParamById($tableName, $atrName, $atrValue, $key, $value)
 {
     $sql = "UPDATE " . $tableName . " set ";
     for ($i = 0; $i < sizeof($atrName); $i++) {
         $sql .= $atrName[$i] . "='" . $atrValue[$i] . "'";
         if ($i < sizeof($atrName) - 1) {
             $sql .= ',';
         }
     }
     $sql .= ' where ' . $key . "=" . $value;
     $db = new DB();
     $db->open();
     if (mysql_query($sql)) {
         //$key不要单引号
         $db->close();
         return true;
     } else {
         $db->close();
         return false;
     }
 }
Esempio n. 24
0
 static function setUpBeforeClass()
 {
     DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
     DB::execute('create table mymodel ( id integer primary key, name char(32), extra text )');
 }
Esempio n. 25
0
 static function setUpBeforeClass()
 {
     DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
 }
Esempio n. 26
0
	$configFile = $_SERVER['COORG_CONFIGFILE'];
}
copy($configFile, 'config/temp.config.tests.php');
$configFile = 'config/temp.config.tests.php';
define('COORG_TEST_CONFIG_CLEAN', $configFile.'.clean');
define('COORG_TEST_CONFIG', $configFile);

$config = new Config($configFile);
$config->set('mollom/public', 'valid-pub-key');
$config->set('mollom/private', 'valid-priv-key');
$config->set('mollom/serverlist', array('valid-server-list'));
$config->set('enabled_plugins', array('search', 'spam', 'admin', 'menu', 'user', 'comments', 'user-admin', 'blog', 'page', 'puntstudio-users'));
$config->set('site/title', 'The Site');
$config->save();
copy($configFile, 'config/temp.config.tests.php.clean');
DB::open($config->get('dbdsn'), $config->get('dbuser'), $config->get('dbpass'));

CoOrg::init($config, 'coorg/testing/plugins-app', 'plugins'); // Load the models


function prepare($plugins)
{
	foreach (array_reverse($plugins) as $p)
	{
		if (file_exists('plugins/'.$p.'/install.php'))
		{
			include_once 'plugins/'.$p.'/install.php';
			
			$f = str_replace('-', '_', $p);
			call_user_func($f.'_delete_db', true);
		}
Esempio n. 27
0
			$config = preg_replace ('/site_name = .*(?:\r\n|\r|\n)/', 'site_name = "' . $_POST['site_name'] . '"'. PHP_EOL, $config, 1);
			$config = preg_replace ('/email_from = .*(?:\r\n|\r|\n)/', 'email_from = "' . $_POST['email_from'] . '"'. PHP_EOL, $config, 1);
			$config = preg_replace ('/site_key = .*(?:\r\n|\r|\n)/', 'site_key = "' . md5 (uniqid (rand (), true)) . '"'. PHP_EOL, $config, 1);
			if (! file_put_contents ('../conf/config.php', $config)) {
				$data['error'] = __ ('Failed to write to conf/config.php');
			} else {
				// create the admin user now
				$conf = parse_ini_file ('../conf/config.php', true);
				$conf['Database']['master']['master'] = true;
				if (isset ($conf['Database']['master']['file'])) {
					$conf['Database']['master']['file'] = '../' . $conf['Database']['master']['file'];
				}

				DB::$prefix = $conf['Database']['prefix'];

				if (! DB::open ($conf['Database']['master'])) {
					$data['error'] = DB::error ();
				} else {
					$date = gmdate ('Y-m-d H:i:s');
					if (! DB::execute (
						"update `#prefix#user` set `email` = ?, `password` = ?, `name` = ? where `id` = 1",
						$_POST['email_from'],
						encrypt_pass ($_POST['pass']),
						$_POST['your_name']
					)) {
						$data['error'] = DB::error ();
					} else {
						$data['ready'] = true;
					}
				}
			}
Esempio n. 28
0
<?php 
require_once("../model/db.php");
require_once("../model/user.php");
?>

<h2>Delete User</h2>

<?php
	$userID = $_GET["userID"];
	if($userID == NULL)
	{
		echo "Invalid user ID: " . $userID;
		return;
	}
	$db = new DB();
	$db->open();
	if(FALSE)
	{
		$db->deleteUserByID($userID);	
		echo "User " . $userID . " deleted successfully.";
	} else {
		echo "User " . $userID . " not deleted.";
	}
	$db->close();
?>
Esempio n. 29
0
function displayItem($action = '')
{
    //print 'ACTION: '.$action.'<br>';
    switch ($action) {
        case "intro":
            showIntro();
            break;
        case "clearsession":
            session_destroy();
            break;
        case "logout":
            session_destroy();
            break;
        case "authenticates":
            if (0) {
                /* If oauth_token is missing get it */
                if ($_REQUEST['oauth_token'] != NULL && $_SESSION['oauth_state'] === 'start') {
                    $_SESSION['oauth_state'] = $state = 'returned';
                }
                print "State: " . $state . "<br>";
                switch ($state) {
                    default:
                        /* Create TwitterOAuth object with app key/secret */
                        $to = new TwitterOAuth($consumer_key, $consumer_secret);
                        /* Request tokens from twitter */
                        $tok = $to->getRequestToken();
                        /* Save tokens for later */
                        $_SESSION['oauth_request_token'] = $token = $tok['oauth_token'];
                        $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
                        $_SESSION['oauth_state'] = "start";
                        /* Build the authorization URL */
                        $request_link = $to->getAuthorizeURL($token);
                        /* Build link that gets user to twitter to authorize the app */
                        $content = 'Click on the link to go to twitter to authorize your account.';
                        $content .= '<a href="' . $request_link . '">' . $request_link . '</a>';
                        break;
                    case 'returned':
                        /* If the access tokens are already set skip to the API call */
                        if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) {
                            /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */
                            $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']);
                            /* Request access tokens from twitter */
                            $tok = $to->getAccessToken();
                            /* Save the access tokens. Normally these would be saved in a database for future use. */
                            $_SESSION['oauth_access_token'] = $tok['oauth_token'];
                            $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret'];
                        }
                        /* Random copy */
                        $content = 'your account should now be registered with twitter. Check here:<br />';
                        $content .= '<a href="https://twitter.com/account/connections">https://twitter.com/account/connections</a>';
                        /* Create TwitterOAuth with app key/secret and user access key/secret */
                        $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
                        /* Run request on twitter API as user. */
                        //Nathaniel's Additions
                        $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
                        $xml = new SimpleXMLElement($to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'));
                        print_r($to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'));
                        //print "|" . $_SESSION['oauth_access_token'] . " -- " . $_SESSION['oauth_access_token_secret'] . "|<br>";
                        $userobj = new User($xml, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
                        //print "|" . $_SESSION['oauth_access_token'] . " -- " . $_SESSION['oauth_access_token_secret'] . "|<br>";
                        //session_start();
                        $_SESSION['userLoggedInID'] = (string) $userobj->userid;
                        $userobj->display();
                        $db = new DB();
                        $db->open();
                        $db->insertUser($userobj);
                        $db->close();
                        break;
                }
                print 'User ID: ' . $_SESSION['userLoggedInID'] . '<br>';
                print_r($content);
            }
            break;
        case "loginas":
            if (!$_GET["id"]) {
                print 'Missing login id';
            }
            $db = new DB();
            $db->open();
            $thisuser = $db->getUserByID($_GET["id"]);
            $db->close();
            logInUser($thisuser);
            $thisuser->display();
            print 'Welcome ' . $_SESSION['userLoggedInName'] . '  <a href="./index.php?act=logout">Log Out</a><br>';
            break;
        case "login":
            print '
			<form name="login" action="index.php" method="get">
			Username:
			<input type="text" name="user" /><br>
			Password:
			<input type="password" name="pass"/><br>
			<input type="hidden" name="act" value="handlelogin"/>
			<input type="submit" value="Submit" />
			</form>
		';
            $text = $_GET["text"];
            break;
        case "handlelogin":
            if (!$_GET["user"] || !$_GET["pass"]) {
                print '<b> Log in to TweetSampler: </b><br>';
                print '
			<form name="login" action="index.php" method="get">
			Username:
			<input type="text" name="user" /><br>
			Password:
			<input type="password" name="pass"/><br>
			<input type="hidden" name="act" value="handlelogin"/>
			<input type="submit" value="Submit" />
			</form>
			';
            } else {
                $db = new DB();
                $db->open();
                if ($db->getUserLoggedIn($_GET["user"], $_GET["pass"])) {
                    print 'Success';
                } else {
                    print 'Failure';
                }
                $db->close();
            }
            break;
        case "updatestatus":
            print '<form name="input" action="" method="post">
		Tweet Content:<br>
		<textarea onkeyup="lengthchange(this);" id="tweettext" cols="50" rows="3"></textarea><br>
		Remaining: <span id="remaining">140</span> characters 
		<input type="button" value="Post" onClick="javascript:submitPost(\'' . $_SESSION["userLoggedInScreenName"] . '\');"/>
		</form>
		<span id="aftersubmit"></span>';
            break;
        case "oldupdatestatus":
            $t = new twitter();
            $text = $_GET["text"];
            echo "<b>Update Status: <b><br>";
            echo $text;
            $tweet = $t->update($text);
            if ($tweet != NULL) {
                $tweet->display();
            } else {
                print 'Error - Status update not posted.';
            }
            break;
        case "ajaxupdatestatus":
            $t = new twitter();
            $text = $_GET["text"];
            echo "<b>Update Status: <b><br>";
            echo $text;
            $t->update($text);
            break;
        case "updatetweets":
            $t = new twitter();
            echo "<b>Update Tweets: <b><br>";
            $t->showZoomedTweets(0, 300);
            break;
        case "deletetweets":
            $db = new DB();
            $db->open();
            echo "<b>Delete Tweets: <b><br>";
            $db->deleteAllTweets();
            $db->close();
            break;
        case "deleteusertweets":
            $db = new DB();
            $db->open();
            echo "<b>Delete User Tweets: <b><br>";
            $db->deleteUserTweets();
            $db->close();
            break;
        case "readtweet":
            $db = new DB();
            $db->open();
            $id = $_GET["id"];
            $db->readTweetByID($id);
            $db->close();
            break;
        case "showallusers":
            $db = new DB();
            $db->open();
            echo "<b>Show All Users: <b><br>";
            $db->getAllUsers();
            $db->close();
            break;
        case "showzoomedtweets":
            print '<div class="slider" id="slider01">
			<div class="left"></div>
			<div class="right"></div>
			<img src="img/knob.png" width="31" height="15" />
		</div>
		<div id="results">Results</div>';
            //Show zoomedTweets
            //for($i=1;$i<=20;$i++){
            //	print "<a href='./index.php?act=showzoomedtweets&zoom=". $i ."'> ". $i ." </a>";
            //	if($i != 20){
            //		print "|";
            //	} else {
            //		print "<br>";
            //	}
            //}
            //$db = new DB();
            //$db->open();
            //echo "<b>Show Zoomed Tweets: <b><br>";
            //$zoom = $_GET["zoom"];
            //$db->getZoomedTweets($zoom);
            //$db->close();
            break;
        case "showalltweets":
            $db = new DB();
            $db->open();
            echo "<b>Show All Tweets: </b><br>";
            $db->getAllTweetsUserBlind();
            $db->close();
            break;
        case "showallmytweets":
            $db = new DB();
            $db->open();
            echo "<b>Show All Tweets: </b><br>";
            $db->getAllTweets();
            $db->close();
            break;
        case "showunreadtweets":
            $db = new DB();
            $db->open();
            echo "<b>Show Unread Tweets: </b><br>";
            $db->getAllUnreadTweets();
            //$db->getXUnreadTweets();
            $db->close();
            break;
        case "showreadtweets":
            $db = new DB();
            $db->open();
            echo "<b>Show read Tweets: </b><br>";
            $db->getAllReadTweets();
            $db->close();
            break;
        case "showlocaltweet":
            $db = new DB();
            $db->open();
            echo "<b>Show Tweet by ID: </b><br>";
            $tweetid = $_GET["id"];
            if ($tweetid == NULL) {
                print "No tweetid entered.  Please try again";
                break;
            }
            $tweet = $db->getTweetByID($tweetid, $_SESSION['userLoggedInID']);
            if ($tweet == -1) {
                print 'Ooops - Tweet not found locally<br>';
            } else {
                $tweet->display();
            }
            $db->close();
            break;
        case "showlocaluser":
            print ' showlocaluser';
            $db = new DB();
            $db->open();
            echo "<b>Show User by ID: </b><br>";
            $userid = $_GET["id"];
            $user = $db->getUserByID($userid);
            $user->display();
            $db->close();
            break;
        default:
            showIntro();
    }
}