function handler() { global $ARI_VERSION; // version $ari_version = $ARI_VERSION; // check error $error = $_SESSION['ari_error']; // load modules loadModules(); // login to database $success = databaseLogon(); if ($success) { // check if login is needed $content = loginBlock(); if (!isset($content)) { list($nav_menu, $subnav_menu, $content) = handleBlock(); } } else { $display = new Display(); $content .= $display->displayHeaderText("ARI"); $content .= $display->displayLine(); $content .= checkErrorMessage(); } // log off any databases needed databaseLogoff(); // check for ajax request and refresh or if not build the page if (isset($_REQUEST['ajax_refresh'])) { echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n <response>\n <nav_menu><![CDATA[" . $nav_menu . "]]></nav_menu>\n <subnav_menu><![CDATA[" . $subnav_menu . "]]></subnav_menu>\n <content><![CDATA[" . $content . "]]></content>\n </response>"; } else { // build the page include_once "./theme/page.tpl.php"; } }
/** * $scroll tell whether you want scroll to the bottom after this call (only used on the initial call, when the page loads) */ function loadChatbox($scroll) { if (!isset($_COOKIE['email'])) { loginBlock(); return; } $lastSender = ''; $html = ' <div id="chatboxMessages"> <table id="chatboxMessagesTable" class="table no-highlight">'; $lighter = " class = 'lighter' "; $sql = 'SELECT * FROM `chatboxMessage` ORDER BY timeSent asc;'; $results = mysql_query($sql); while ($row = mysql_fetch_array($results)) { if ($lastSender == $row["sender"]) { $sender = ''; } else { $sender = $row["sender"]; $sql = "SELECT * FROM `member` WHERE email='" . $sender . "';"; $result = mysql_fetch_array(mysql_query($sql)); $sender = $result["prefName"] . " " . substr($result['lastName'], 0, 1) . ": "; $timeInt = strtotime($row["timeSent"]); $time = date("H:i", $timeInt); $day = date("M d", $timeInt); } $contents = $row["contents"]; $messageID = $row['messageID']; /*if(strpos($contents, 'www.') === 0){ $contents = '<a href="'.$contents.'" target="_blank">surprise link</a>'; } if(strpos($contents, 'http://') === 0){ $contents = '<a href="'.$contents.'" target="_blank">surprise link</a>'; }*/ $temp = ''; $words = explode(' ', $contents); foreach ($words as $value) { $link = ''; if (strpos($value, 'www.') === 0 || strpos($value, 'http://') === 0 || strpos($value, 'https://') === 0) { $link = $value; $domain = explode('/', $link); if ($domain[0] !== "http:" && $domain[0] !== "https:") { $domainDisplay = $domain[0]; } else { $domainDisplay = $domain[2]; } //get just 'youtube' or 'imgur' //$domainBits = explode('.', $domainDisplay); $value = '<a href="' . $link . '" target="_blank">' . $link . '</a>'; } if (strpos($link, '.jpg') || strpos($link, '.gif') || strpos($link, '.png')) { $value = '<div class="btn" onclick="showChatboxImage(this);">show image</div><img class="chatboxImage" src="' . $link . '" onclick="hideChatboxImage(this);"/>'; } $temp .= ' ' . $value; } $contents = $temp; //this goes backwards. the first sql result is the last (most recent) one that appears onscreen. builds from the bottom up. $html = $html . "\n\t\t\t<tr " . $lighter . ">\n\t\t\t\t<td>\n\t\t\t\t\t<span class='chatboxTimestamp'><span>" . $day . " </span>\n\t\t\t\t\t<span>" . $time . "</span></span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<dl class='dl-horizontal'>\n\t\t\t\t\t\t<dt>\n\t\t\t\t\t\t\t<span class='chatboxSenderName'>" . $sender . "</span>\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t<dd>\n\t\t\t\t\t\t\t<span data-messageID='" . $messageID . "' class='chatboxMessage'>" . $contents . "</span>\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t</dl>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t"; //put in a submit button $lastSender = $row["sender"]; if ($lighter == '') { $lighter = " class = 'lighter' "; } else { $lighter = ''; } } $html .= "\n\t\t<tr " . $lighter . ">\n\t\t\t\t<td>\n\t\t\t\t\t<span class='chatboxTimestamp'><span></span>\n\t\t\t\t\t<span>now</span></span>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<dl class='dl-horizontal'>\n\t\t\t\t\t\t<dt>\n\t\t\t\t\t\t\t<span class='chatboxSenderName'>You:</span>\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t<dd>\n\t\t\t\t\t\t\t<div class='control-group form-inline'>\n\t\t\t\t\t\t\t\t<input type='text' id='shoutBox' />\n\t\t\t\t\t\t\t\t<div class='btn btn-primary' id='shoutButton'>shout</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t</dl>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</div>"; //make it all the same table so everything lines up //if this is the first time loading the page if ($scroll == '1') { //wrap the whole page in a 'scrolldiv', and have javascript can scroll to the bottom $html = "\n\t\t<div id='scrolldiv'>\n\t\t\t{$html}\n\t\t</div>\n\n\t\t<script type='text/javascript'>\n\t\t\twindow.scrollBy(0, \$('#scrolldiv').height());\n\t\t</script>"; } echo $html; }
<?php //it would seem you cannot connect to the database from outside a function and inside a function require_once 'functions.php'; if (!$USER) { loginBlock(); exit(1); } function user_money_table($memberID) { global $CHOIR; $sql = "select * from `transaction` where `memberID` = '{$memberID}' and `choir` = '{$CHOIR}' and `resolved` = '0' order by time desc"; $transactions = mysql_query($sql); if (mysql_num_rows($transactions) == 0) { return "<span style='color: gray'>(No transactions)</span><br>"; } $html = "<table style='width: 100%'>"; $count = 0; while ($transaction = mysql_fetch_array($transactions)) { $time = $transaction['time']; $amount = $transaction['amount']; $description = $transaction['description']; $id = $transaction['transactionID']; $type = $transaction['type']; $sem = $transaction['semester']; $time = strftime("%b %d, %Y", strtotime($time)); $sql = "select `name` from `transacType` where `id` = '{$type}'"; $result = mysql_fetch_array(mysql_query($sql)); $typename = $result['name']; $desc = ''; if ($type == 'dues' || $type == 'deposit') {