<?php require_once "./xmlWriter.php"; require_once '../database/Database.php'; $database = new Database('master'); $comName = $_GET['communityName']; $userId = $_GET['userId']; $query = 'SELECT id FROM communities WHERE name = "' . $comName . '"'; $query = $database->query($query); if (mysql_num_rows($query) > 0) { echo "-1"; } else { $xml = new cXmlWriter(); $xml->push("NewlyInsertedCommunity"); $xml->push("CommunityInformation"); $time = time(); $query = 'INSERT INTO communities (user, name, created) VALUES("' . $userId . '", "' . $comName . '", "' . $time . '")'; $database->query($query); $communityId = mysql_insert_id(); // store the community id and name // get the creator of the community group $creatorQuery = "SELECT user FROM communities WHERE id = '" . $communityId . "'"; $creatorResult = mysql_query($creatorQuery); $creatorId = mysql_result($creatorResult, 0, "user"); $creatorQuery = "SELECT username FROM users WHERE id = '" . $creatorId . "'"; $creatorResult = mysql_query($creatorQuery); $creatorName = mysql_result($creatorResult, 0, "username"); $xml->element("communityGroupId", $communityId);
if (mysql_num_rows($q) == 0) { $time = time(); //echo "New website\n"; $q = 'INSERT INTO websites (user, community, name, created, type, scrapeNumTopLevel, scrapeInterval) VALUES ( "' . $userId . '", "' . $communityId . '", "' . $websiteName . '", "' . $time . '", "' . $type . '", "' . $scrapeNumTopLevel . '", "' . $scrapeInterval . '")'; $database->query($q); $websiteId = mysql_insert_id(); // declare the return storage XML object $xml = new cXmlWriter(); $xml->push("head"); $xml->push("WebsiteInformation"); // store the website information in the XML return object $xml->element("id", $websiteId); $xml->element("communityId", $communityId); $xml->element("name", $websiteName); $xml->element("createdTime", $time); $xml->element("type", $type); // create the database for this new website $database = new Database('root'); $database->query('CREATE DATABASE IF NOT EXISTS ' . $websiteName); $database = new Database($websiteName); $database->query(file_get_contents('../database/website.txt'), true); // insert regexes $q = 'INSERT INTO regexes
$num_rows = mysql_num_rows($query); if ($num_rows > 0) { echo "-1"; } else { $time = time(); $query = 'INSERT INTO websites (user, community, name, created, type) VALUES("' . $userId . '", "' . $community . '", "' . $websiteName . '", "' . $time . '", "' . $type . '")'; $database->query($query); $websiteId = mysql_insert_id(); $database = new Database('root'); $database->query('CREATE DATABASE ' . $websiteName); $database = new Database(strtolower($websiteName)); // causes problem $database->query(file_get_contents('./database/website_temp.txt')); $xml = new cXmlWriter(); $xml->push("NewlyInsertedWebsite"); $xml->push("WebsiteInformation"); // store the website id, name, and URL $xml->element("websiteId", $websiteId); $xml->element("websiteName", $websiteName); $xml->element("websiteURL", $websiteURL); $xml->element("websiteType", $type); $xml->element("websiteCreatedTime", $time); $xml->pop(); $xml->pop(); echo $xml->getXML(); }
$query = "SELECT id FROM allowedkeywords WHERE community = '" . $communityId . "' AND word = '" . $name . "'"; $result = $database->query($query); $xml = new cXmlWriter(); $xml->push("NewKeyword"); $xml->push("Information"); $id = mysql_result($result, 0, "id"); $xml->element("id", $id); $xml->element("communityId", $communityId); $xml->element("name", $name); $xml->element("type", "ak"); $xml->pop(); $xml->pop(); echo $xml->getXML(); } else { if ($type === "rw") { $database->query("DELETE FROM websites WHERE community = '" . $communityId . "' AND name = '" . $name . "'"); $database = new Database('root'); $database->query("DROP DATABASE " . $name); $xml = new cXmlWriter(); $xml->push("RemoveWebsite"); $xml->push("Information"); $xml->element("name", $name); $xml->element("communityId", $communityId); $xml->pop(); $xml->pop(); echo $xml->getXML(); } else { echo "-1"; } } }
$xml = new cXmlWriter(); $xml->push("LoggedInAccountInformation"); $xml->push("UserAccountInformation"); $xml->pop(); $xml->pop(); echo $xml->getXML(); } else { $q = mysql_fetch_array($q); $_SESSION['userId'] = $q['id']; $realName = 'SELECT realName FROM users WHERE username = "******" AND password = password("' . $password . '")'; $realName = $database->query($realName); $realName = mysql_fetch_array($realName); $xml = new cXmlWriter(); $xml->push("LoggedInAccountInformation"); // store the user account information $xml->push("UserAccountInformation"); $xml->element("fullName", $realName[0]); $xml->element("email", $email); $xml->element("password", $password); $xml->element("userId", $q[0]); $xml->pop(); // store the user's community group information along with the websites // and keywords $xml->push("MyCommunityGroups"); $query = 'SELECT * FROM communities WHERE user = "******"'; $result = $database->query($query); $num_rows = mysql_num_rows($result); $xml->element("NumberOfCommunityGroups", $num_rows);
$communityId = $_GET['community']; $websiteName = $_GET['websiteName']; $database = new Database('communityanalysis'); $q = 'SELECT * FROM allowedkeywords WHERE community = "' . $communityId . '"'; // grab all of the keywords which pertain to the community passed in $q = $database->query($q); $keywordArray = array(); for ($i = 0; $i < mysql_num_rows($q); $i++) { $keywordArray[$i] = mysql_result($q, $i, "word"); } // switch over to the database which represents our website //$database = new Database($websiteName); $database = new Database($websiteName); // create an XML object $xml = new cXmlWriter(); $xml->push("WebsiteAnalytics"); $xml->push("Information"); $xml->element("communityId", $communityId); $xml->element("websiteName", $websiteName); $xml->pop(); // Keyword Data Section starts here $xml->push("Keywords"); // loop through database keywords and try to fetch each one // from the website database keyword list $counter = 0; for ($i = 0; $i < count($keywordArray); $i++) { $q = 'SELECT id FROM keywords WHERE word = "' . $keywordArray[$i] . '"'; $q = $database->query($q); if (mysql_num_rows($q) > 0) { // store the keyword
<?php require_once "./xmlWriter.php"; // connect to the mySQL server and select the database $host = 'csil-srprj-2.cs.uiuc.edu'; $user = '******'; $password = '******'; $link = mysql_connect($host, $user, $password) or die('Could not connect: ' . mysql_error()); mysql_select_db('communityanalysis') or die('Could not select database<br/>'); $query = "SELECT * FROM websites"; $result = mysql_query($query); $xml = new cXmlWriter(); $xml->push("head"); $xml->push("AllWebsites"); $xml->element("numberOfWebsites", mysql_num_rows($result)); for ($i = 0; $i < mysql_num_rows($result); $i++) { $xml->push("Website" . $i); $id = mysql_result($result, $i, "id"); $name = mysql_result($result, $i, "name"); $type = mysql_result($result, $i, "type"); $xml->element("id", $id); $xml->element("name", $name); $xml->element("type", $type); $xml->pop(); } $xml->pop(); $xml->pop(); echo $xml->getXML();
// hostname or ip of server (for local testing, localhost should work) $dbServer = 'localhost'; // username and password to log onto db server $dbUser = '******'; $dbPass = '******'; // name of database $dbName = 'communityanalysis'; $link = mysql_connect("{$dbServer}", "{$dbUser}", "{$dbPass}") or die("Could not connect"); //print "Connected successfully<br>"; mysql_select_db("{$dbName}") or die("Could not select database"); //print "Database selected successfully<br>"; $query = 'SELECT * FROM websites'; $result = mysql_query($query, $link); // get the number of rows for the table $num_rows = mysql_num_rows($result); $xml = new cXmlWriter(); $xml->push("MasterRecordsDatabase"); $xml->push("Communities"); for ($i = 0; $i < $num_rows; $i++) { $xml->push("Community" . $i); $xml->element("id", mysql_result($result, $i, "id")); $xml->element("domain", mysql_result($result, $i, "domain")); $xml->element("type", mysql_result($result, $i, "type")); $xml->pop(); } $xml->pop(); $xml->pop(); echo $xml->getXML(); /* if($_GET['getData1'] == "1") {
<?php // hostname or ip of server (for local testing, localhost should work) $dbServer = 'localhost'; // username and password to log onto db server $dbUser = '******'; $dbPass = '******'; // grab the arguments passed from the HTTPService component $array = array($_GET["mArgsArray"]); // grab the database name as the first argument in $array $dbName = $array[0]; $link = mysql_connect("{$dbServer}", "{$dbUser}", "{$dbPass}") or die("Could not connect"); mysql_select_db("{$dbName}") or die("Could not select database"); $xml = new cXmlWriter(); $xml->push("ForumCommunitySingleDatabase"); $xml->push("BasicAnalysis"); // parse the users table for entries and store them in the XML $query = 'SELECT * FROM analysis'; $result = mysql_query($query, $link); // get the number of rows for the table $num_rows = mysql_num_rows($result); // store the user data table data in the xml $xml->push("analysis"); for ($i = 0; $i < $num_rows; $i++) { $xml->push("Block" . $i); if (mysql_result($result, $i, "type") == "id") { if (mysql_result($result, $i, "table") == "keywords") { $xml->element("type", "keywords"); $xml->element("field", mysql_result($result, $i, "field")); $id = mysql_result($result, $i, "value"); $xml->element("word", mysql_result(mysql_query("SELECT * FROM keywords WHERE id = {$id}", $link), 0, "word"));